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 trialChristian Hingle
15,495 PointsIncrementing Confusion
Introduction to Programming Course
Arrays Video
At 14:09 of the video, after adding the incrementer to his friends loop and running the script in the browser, he says the loop starts with Nick. Yet if you look at the console, it starts with Michael, then goes to Nick, then back to Michael, then the rest of his friend's names. Is that how the output was supposed to look or did he do something wrong there?
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Christian,
The 1st Michael was from the following code before the for loop:
var friendNumber = 1;
console.log(friends[friendNumber]);
That logged Michael then the for loop started with Nick, then Michael, etc...
Each time the page is refreshed it's running all of the script. Not just the newest code he has added.
Christian Hingle
15,495 PointsOkay thanks Jason. Now I understand it. I have to admit these Javascript videos are a bit tough to follow.