Tell us what’s happening:
I have a question, why my code isn’t correct? It looks like it’s working exactly like it would. Can anyone tell me what I do wrong here?
Your code so far
function repeatStringNumTimes(str, num) {
let string=[];
if (num<=0) {return ''}
else {
for (let i=0; i<num; i++){
string.push(str);
}
return console.log(string.join(''));
}
}
repeatStringNumTimes("*", 5);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 OPR/90.0.4480.117
Challenge: Basic Algorithm Scripting - Repeat a String Repeat a String
Link to the challenge: