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!
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
Alessandro Romani
19,723 PointsWhile in Chrome
Hello, can someone explain why in chorme this snippet writes numbers from 0 to 10? var i = 0; while (i < 10) { console.log(i); i=i+1; } This other instead seems to work correctly: var i = 0; while (i < 10) { console.log(i); i++; } In Edge both work the same;
1 Answer

Alessandro Romani
19,723 PointsI think the difference is due to the fact that chrome shows the last value evaluated apart the result of console.log, so after the last console.log i++ (++i act like i=i+1) is evaluated 9 whereas i=i+1 is evaluated 10;