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 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
217,574 Points

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

Mark Casavantes
Mark Casavantes
10,606 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.