this is not an empty string, it is a string which contains space
What if num equals 0. Instruction is Return an empty string if num is not a positive number.
Consider to read this, if you haven’t yet
Look at this part The concat() function concatenates the string arguments to the calling string and returns a new string. Changes to the original string or the returned string don't affect the other.
If we add some logs to your code:
function repeatStringNumTimes(str, num) {
let newStr = " ";
if ( num < 0) {
return str = " ";
} else {
for (let i = 0; i < num; i++) {
console.log(`i equals ${i} for current iteration`)
console.log(`newStr is ${newStr}`)
console.log(`length of newStr now is ${newStr.length}`)
newStr.concat(str);
}
}
console.log(newStr)
return newStr;
}
repeatStringNumTimes("abc", 3);
we will see that newStr value is not changing as loop keeps going.
minor note: it is up to you - to use concat() or not, but it is worth mentioning, that some non-english versions of MDN article about .concat() recommend using + or += operators instead when it is possible due to perfomance