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

11 lines
210 B
JavaScript
Raw Normal View History

2022-02-20 19:07:44 +00:00
const repeatString = function (word, times) {
2023-01-21 17:53:41 +00:00
if (times < 0) return "ERROR";
let string = "";
for (let i = 0; i < times; i++) {
string += word;
}
return string;
2022-02-20 19:07:44 +00:00
};
module.exports = repeatString;