-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrepeat.js
More file actions
23 lines (20 loc) · 789 Bytes
/
repeat.js
File metadata and controls
23 lines (20 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict'
/*
* Create a function `repeat` that takes a String and a Number
* and return the repeated string by the given number
* Like the method https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
* Of course you may not use the method directly
*
* @next sentence
*/
//* Begin of tests
const assert = require('assert')
assert.strictEqual(typeof repeat, 'function')
assert.strictEqual(repeat.length, 2)
assert.strictEqual(repeat.toString().includes('.repeat'), false)
assert.strictEqual(repeat('a', 3), 'aaa')
assert.strictEqual(repeat('ba', 10), 'babababababababababa')
assert.strictEqual(repeat('pouet', 2), 'pouetpouet')
assert.strictEqual(repeat('haha', 1), 'haha')
assert.strictEqual(repeat('hehehe', 0), '')
// End of tests */