Hi guys, I’m really stumped with this one. I’m resisting the temptation to hit up the blog posts and wikis on this challenge because it seems really simple and I should have no problem with it. That said, my code is just returning an empty string and I have no idea why.
Here it is:
function repeatStringNumTimes(str, num) {
var returnStr = "";
if (num < 1) {
return "";
} else {
for (i = 0; i < num; i++) {
returnStr.concat(str);
}
return returnStr;
}
}
repeatStringNumTimes("abc", 3);
I know that this isn’t caused by the if statement’s empty string because this persists even if I comment-out the if statement. What am I doing wrong here?