Update repeatString.js

repeat string function completed
This commit is contained in:
Archybella 2023-08-08 15:18:17 +03:00 committed by GitHub
parent dd9a83068d
commit 9ae464672a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,13 @@
const repeatString = function() { const repeatString = function(word, times) {
let result = '';
for (let i = 0; i < times; i++) {
result += word;
}
return result;
}; };
// Test the repeatString function
const repeatedWord = repeatString('apple', 3);
console.log(repeatedWord); // Output: "appleappleapple"
// Do not edit below this line // Do not edit below this line
module.exports = repeatString; module.exports = repeatString;