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

Hi there, I can get my answer to run in the javascript console, however I'm getting a parse error when I submit.

Hi there, I have trouble when submitting my answer: parse error. I have copied and pasted my answer into the javascript console in google chrome and there is no error; the code appears to run without error.

Can anyone help me understand where I have gone wrong?

Thank you in advance for any assistance you can provide.

Cheers, Jacob

script.js
var count = 0;
while (count <= 25) {
             document.write(`This is loop # ${count}` );
        count += 1;
       }
var count = 0;
while (count <= 25) {
             document.write("This is loop "+ count);
        count += 1;
       }

2 Answers

Steven Parker
Steven Parker
229,732 Points

This challenge engine apparently has not been upgraded to handle ES2015 syntax (template literals in particular).

But you don't need to output the count, you can just output 26 of anything.

    document.write("anything");

Many thanks for the help on this one, Steven Parker and teofanescucosmin.

I'll remove the template literals and use

document.write("This is loop "+ count)

Thanks again