From 9ae464672a5b7502bd126d2d7a854e1f49c6b29e Mon Sep 17 00:00:00 2001 From: Archybella <128797928+Archybella@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:18:17 +0300 Subject: [PATCH] Update repeatString.js repeat string function completed --- 02_repeatString/repeatString.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/02_repeatString/repeatString.js b/02_repeatString/repeatString.js index 4359bbe..144f9ab 100644 --- a/02_repeatString/repeatString.js +++ b/02_repeatString/repeatString.js @@ -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 module.exports = repeatString;