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

Angelica Islas
Angelica Islas
4,082 Points

I am trying to complete a challenge where the selected language is JavaScript(Node.js).

I entered in the following code in the challenge and received the message that there was a SyntaxError: Unexpected end of input

I copied and pasted my code and the output that I entered in the JS console: var playerRanks= [1,2,3,4,5]; for (let i=1; i<5; i++){ console.log (i);

}

VM139:3 1 VM139:3 2 VM139:3 3 VM139:3 4 undefined

So my question to reiterate is why do I get an output in JS console but not in my challenge when the language selected is JavaScript(Node.js).

I appreciate some insight. Thank you.

1 Answer

I believe that the issue in your code is that your are trying i value in the for loop as the numbers inside the [] when you actually need to be using the index looping through playerranks.length.

Hope it helps.