Merge pull request #3990 from abhisekp/fix/waypoint-for-loop

Instructional clarification for Waypoint - Iterate with JavaScript For Loops
This commit is contained in:
Logan Tegman
2015-10-29 15:48:06 -07:00

View File

@ -868,16 +868,16 @@
"The most common type of JavaScript loop is called a \"for loop\" because it runs \"for\" a specific number of times.",
"For loops are declared with three optional expressions seperated by semicolons:",
"<code>for([initialization]; [condition]; [final-expression])</code>",
"The <code>initialization</code> statement is executed one time only before the loop starts. It is typically used to define and setup your loop varaible.",
"The <code>condition</code> statement is evaluated at the beginning of every loop and will continue as long as it evalutes <code>true</code>. When <code>condition</code> is <code>false</code> at the start of the loop, the loop will stop executing. This means if <code>condition</code> starts as <code>false</code>, your loop will never execute.",
"The <code>initialization</code> statement is executed one time only before the loop starts. It is typically used to define and setup your loop variable.",
"The <code>condition</code> statement is evaluated at the beginning of every loop iteration and will continue as long as it evalutes to <code>true</code>. When <code>condition</code> is <code>false</code> at the start of the iteration, the loop will stop executing. This means if <code>condition</code> starts as <code>false</code>, your loop will never execute.",
"The <code>final-expression</code> is executed at the end of each loop iteration, prior to the next <code>condition</code> check and is usually used to increment or decrement your loop counter.",
"We'll initialize with <code>i = 0</code> and loop while our condition <code>i < 5</code> is true. We'll increment <code>i</code> by 1 each loop with <code>i++</code> as our <code>final-expression</code>.",
"In the following example we initialize with <code>i = 0</code> and iterate while our condition <code>i < 5</code> is true. We'll increment <code>i</code> by <code>1</code> in each loop iteration with <code>i++</code> as our <code>final-expression</code>.",
"<code>var ourArray = [];</code>",
"<code>for(var i = 0; i < 5; i++) {</code>",
"<code>&thinsp;&thinsp;ourArray.push(i);</code>",
"<code>}</code>",
"<code>ourArray</code> will now contain [0,1,2,3,4] ",
"Let's try getting a for loop to work by pushing values to an array."
"<code>ourArray</code> will now contain <code>[0,1,2,3,4]</code>.",
"Let's try getting a <code>for</code> loop to work by pushing values to an array."
],
"tests": [
"assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');",