odin-default-js-exercises/repeatString/repeatString.js

11 lines
203 B
JavaScript

const repeatString = function(word, times) {
if (times < 0) return 'ERROR'
let string = ''
for (let i = 0; i < times; i++) {
string += word
}
return string
}
module.exports = repeatString