Skip to content

Commit 8de2c62

Browse files
committed
8kyu(js): add "Exclamation marks series #2: Remove all exclamation marks
from the end of sentence"
1 parent 1b66463 commit 8de2c62

2 files changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const remove = string => string.replace(/!+$/, '')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { assert } from 'chai'
2+
3+
import { remove } from '../../app/8kyu/exclamation-marks-series-number-2-remove-all-exclamation-marks-from-the-end-of-sentence.js'
4+
5+
describe('tests', () => {
6+
function doTest(input, expected) {
7+
const actual = remove(input)
8+
assert.strictEqual(actual, expected, `for string:\n"${input}"\n`)
9+
}
10+
11+
it('It should work for basic tests', () => {
12+
doTest('Hi!', 'Hi')
13+
doTest('Hi!!!', 'Hi')
14+
doTest('!Hi', '!Hi')
15+
doTest('!Hi!', '!Hi')
16+
doTest('Hi! Hi!', 'Hi! Hi')
17+
doTest('Hi', 'Hi')
18+
})
19+
})

0 commit comments

Comments
 (0)