odin-js-fundamentals-part-4/02_repeatString/solution/repeatString-solution.js

11 lines
210 B
JavaScript
Raw Permalink Normal View History

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;