HEAD
Write a function called repeatStr which repeats the given string string exactly n times.
repeatStr(6, "I") // "IIIIII" repeatStr(5, "Hello") // "HelloHelloHelloHelloHello"
function repeatStr (n, s) {
let i = 0
let str = ""
while(i < n){
str += s
i++
}
return str;
}
Try it yourself - CodeWars
Write a function called repeatStr which repeats the given string string exactly n times.
repeatStr(6, "I") // "IIIIII" repeatStr(5, "Hello") // "HelloHelloHelloHelloHello"
function repeatStr (n, s) {
let i = 0
let str = ""
while(i < n){
str += s
i++
}
return str;
}
Try it yourself - CodeWars