Tell us what’s happening:
hey guys, i am wondering why this one is not working, will appreciate any help
Your code so far
function repeatStringNumTimes(str, num) {
// repeat after me
function recursive_add (str,num,output) {
// console.log("hey",str,num,output)
if (num<0) {
return "xasd"
}
if (num>0) {
// console.log(output)
num=num-1
output=output+str
recursive_add(str,num,output)
}
if (num==0)
{
// console.log(output) -> this one returns correct output
return output
}
}
var x = recursive_add(str,num,"")
console.log("should be correct but is empty :( ",x)
}
repeatStringNumTimes("abc", 3);