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

Prescott Lawani
Prescott Lawani
2,634 Points

[Solved] For loop 4 to 156 not being accepted

I don't see what I'm doing wrong here, but it is giving me an error of unexpected token (i)

script.js
for ( int i = 4; i <= 156; i++){
 console.log(i); 
}

3 Answers

Steven Parker
Steven Parker
231,275 Points

In JavaScript, "int" is not a keyword used to define a variable. Try "var" instead.

Mark Casavantes
Mark Casavantes
10,619 Points

I would eliminate the int on your first line and add + " " to space your answers on your console.log line. I hope this is helpful.

Prescott Lawani
Prescott Lawani
2,634 Points

Oh duh...thanks Steven. I was thinking C#. I can't believe I let that slip my mind.