Freecodecamp: Switch order of 'Basic Javascript' for- and while-loop lessons

Created on 16 Oct 2016  路  7Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Name

Iterate with JavaScript For Loops
Iterate with JavaScript While Loops

Issue Description

Consider moving the lesson "Iterate with JavaScript While Loops" to a position before the series of lessons on for-loops, starting at "Iterate with JavaScript For Loops". Currently the single while-loop lesson is placed after the for-loop lessons, but it may be advantageous for students if its made clear that a for-loop is a condensed form of a while loop (especially since the example code in the lessons are synonymous:

var ourArray = [];
var i = 0;
while(i < 5) {
    ourArray.push(i);
    i++;
}

and:

var ourArray = [];
for (var i = 0; i < 5; i++) {
    ourArray.push(i);
}

Lesson text in the for-loop lessons could then be updated to make the relationship to while-loops more explicit. It could also be stated that while-loops are used for more than just iterating but if you find yourself iterating with a while-loop, that's a good opportunity to use a for-loop instead.

Screenshot

for-while_fcc
while-lesson
for-lesson-1
for-lesson-2

help wanted learn

Most helpful comment

Sounds reasonable to me

cc @FreeCodeCamp/issue-moderators

All 7 comments

Sounds reasonable to me

cc @FreeCodeCamp/issue-moderators

Lets move these challenges around :+1:

Remember to take the translations with you :smiley:

Working on it 馃榿

It took much, much longer to setup than to finish coding this...

one other thing - maybe in the wrong place here (please be kind, I'm new around here :) ) - I wonder about the pros and especially the cons of using while at all. It might be wise to note that a misuse of while could result in an endless loop, leaving your page/app broken and eventually kill the whole browser.
If this is the only place where while is explained, I'd appreciate a note on that.

@boneyfantaseas feel free to head over to the Contributors Gitter chat room for a sounding board for curriculum discussions.

thx!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kokushozero picture kokushozero  路  3Comments

jurijuri picture jurijuri  路  3Comments

ROWn1ne picture ROWn1ne  路  3Comments

ar5had picture ar5had  路  3Comments

trashtalka3000 picture trashtalka3000  路  3Comments