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 for Loop

John Meyers
PLUS
John Meyers
Courses Plus Student 2,582 Points

Why am I getting the syntax error: parse error?

Although I figured out a solution, I would still like to know what is going on here. The code I originally wrote is accepted by every other console I have tried it on.

Original:

let numbers; for (let i = 4; i <= 156; i++) { numbers = i; console.log(numbers); }

As you can see, I am conditioned to using 'const' and 'let' in place of the outdated 'var'. I also replaced 'i += 1' with 'i++'. Again, these are the exact same thing. I would even argue that mine is better because it takes up 1 less character. I have had no problems using this syntax in treehouse workspace. It's only when I am taking a quiz that it gives me problems. Am I missing something here???

Below are the changes I had to make to pass the quiz.

Changes:

var numbers; for (var i = 4; i <= 156; i += 1) { numbers = i; console.log(numbers); }

script.js

1 Answer

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Some challenges here won't take let and const operators which are ES6 operators.