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

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
210,423 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