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

15 lines
294 B
JavaScript

const repeatString = function (word, times) {
if (times < 0) return "ERROR";
let myWord = "";
if (times > 0) {
for (let i = 0; i < times; i++) {
myWord += word;
}
}
return myWord;
};
repeatString("hey", 0);
// Do not edit below this line
module.exports = repeatString;