Tell us what’s happening:
I can run the following code in my browser console, and I am getting the correct answers for all the test cases. However, I am not passing most test cases when I run this code in the freecodecamp editor.
Can someone help me understand why?
Your code so far
function repeatStringNumTimes(str,num){
if (num<0){
return "";
}
else {
var p = str;
let i =0;
while (i <num){
p+=str;
i++
}
console.log(p);
return p;
}
}
repeatStringNumTimes("abc", 3);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string