Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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;

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
231,236 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).

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