created a variable that hold the string. loop through the number of times the string is repeated.

assigned the number time the string is repeated to the variable created
This commit is contained in:
Isah Jacob 2022-10-29 11:05:02 +01:00
parent 342604b4e2
commit 8ec38c4b57
1 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,16 @@
const repeatString = function() {
const repeatString = function(string, num) {
var repeatedWord = "";
while (num > 0){
repeatedWord += string;
num--;
}
return repeatedWord;
};
repeatString('hey', 3);
repeatString('hey', 10);
repeatString('hey', 1);
repeatString('hey', 0);
repeatString('hey', -1)
// Do not edit below this line
module.exports = repeatString;