Console Log indicates code is working. But tests don't pass

Good Afternoon All

First post here, and very much a code novice.
Really having to do a lot of reading on these Basic Algorithm tasks.
Getting beat a lot, but determined to keep returning.

On this one, using the console.log it implies the results should pass (at least) some of the tests. But the ticks don’t appear.
Am I off track somewhere?

  **Your code so far**
function repeatStringNumTimes(str, num) {
var result = " ";
while (num > 0) {
  result += str 
  num = num-1
  
} 
console.log(result)
return result;
} 

repeatStringNumTimes("abc", 2); 
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0

Challenge: Repeat a String Repeat a String

Link to the challenge:

This line is the one causing the problem. Do you really want the finally string to start with a space character?

Just Seen it… Doh!!
Thank you :slight_smile:

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