help:Repeat a String Repeat a String

Tell us what’s happening:
Can anyone explain why this approach doesn’t work? My code meets all the conditions outlined in the challenge. And testing using console.log out confirms that. But it still doesn’t allow me to complete this challenge?

Your code so far


function repeatStringNumTimes(str, num) {

if (num<= 0){ return " "}


else return `${str}${repeatStringNumTimes(str, num - 1)}`;
}

console.log(repeatStringNumTimes("abc", 4))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36.

Challenge: Repeat a String Repeat a String

Link to the challenge:

that’s called template literal, it is not an error

try to print your output, and use the browser console, which let you see it better

You’re placing a space at the end of your return.
Just remove the space on the end, like so: if (num<= 0){ return “”}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.