Fix example if-else statements with clearer example

This commit is contained in:
Eric Leung
2015-11-25 21:48:16 -08:00
parent 5afd061b90
commit 9c3e43e190

View File

@ -1143,10 +1143,11 @@
"We can use <code>if</code> statements in JavaScript to only execute code if a certain condition is met.",
"<code>if</code> statements require some sort of boolean condition to evaluate.",
"For example:",
"<code>if (1 === 2) {</code>",
"<code>&nbsp;&nbsp;return true;</code>",
"<code>var x = 1;</code>",
"<code>if (x === 2) {</code>",
"<code>&nbsp;&nbsp;return 'x is 2';</code>",
"<code>} else {</code>",
"<code>&nbsp;&nbsp;return false;</code>",
"<code>&nbsp;&nbsp;return 'x is not 2';</code>",
"<code>}</code>",
"Let's use <code>if</code> and <code>else</code> statements to make a coin-flip game.",
"Create <code>if</code> and <code>else</code> statements to return the string <code>\"heads\"</code> if the flip variable is zero, or else return the string <code>\"tails\"</code> if the flip variable is not zero."