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

11 lines
209 B
JavaScript
Raw Permalink Normal View History

const repeatString = function(word, times) {
2022-01-23 20:17:39 +00:00
if (times < 0) return 'ERROR';
let string = '';
for (let i = 0; i < times; i++) {
2022-01-23 20:17:39 +00:00
string += word;
}
2022-01-23 20:17:39 +00:00
return string;
};
2017-08-21 15:28:29 +00:00
module.exports = repeatString;