Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a while Loop

Abel Gechure
Abel Gechure
13,608 Points

Syntax error : Parse error

My code looks fine, i have tested it in the browser and it runs and performs the task well. I am trying to complete the challenge but every time i am pressing the button check work, it returns a bummer(error). Is this a bug that has nothing to do with my code or what am i missing?

script.js
var count = 0;
while (count < 27) {
  document.write(`<p>We are now in loop ${count}</p>`);
  count += 1;
}

2 Answers

Hey Abel, So a couple of things here. Apparently the challenge does not appreciate usage of template literals as it doesn't seem like it can be passed by using them. Secondly, you've almost got it except that your code will print to the document 27 times, not 26. The value of count is initialized at '0' and your condition is set to check until value of count variable is less than 27. One simple change will get you there, just set your condition to check for count<26;

Abel Gechure
Abel Gechure
13,608 Points

Hey Seth, thank you very much for the help, I will correct the condition and use string concatenation in place of template literals (which I prefer).

Steven Parker
Steven Parker
210,425 Points

I don't think this challenge is prepared to handle template strings. Try using a plain string for the output (it doesn't need to include the count, but you can use concatenation if you want).

But also check your condition, the loop should run 26 times (and remember the count starts at zero).

Abel Gechure
Abel Gechure
13,608 Points

Thank you very much ! Let me use string concatenation and correct the condition.