Thank you!
I get it, so I am comparing different values of num and then returning an outcome based on its type, correct?
So if the integer is negative or positive, I return different results.
Indeed, it does not make sense.
I am doing that because that is normally the syntax but I guess in this case is different.
Let me try to work it out this time with i === +num inside the if statement
Thanks!
You don’t really need an array here. Again you just need to check if num is not positive (num < 0) in which case you return an empty string. You have to loop over num not str. Pay attention, you’re not returning anything in your else block. You’re on the way, try to refactor and we’re there to help you.
About myArray++
I did that out of guess because in HINT 4 says to make the variable to store the current variable and append the word to it
what does that mean in code?
You’re almost there. Try to refactor your code like this
let newStr = '' // <=== Initialize an empty str here
for(let i= 0; i < num; i++) { // num is already a num, no num.length
if(num < 0) {
return newStr // return newStr that is empty for now or return ''
}
else{
// add str to newStr
newStr += str
}