Fix inconsistent If spacing in Basic Javascript

pull/18182/head
Eric Leung 2016-01-17 15:46:36 -08:00
parent f1919a3ae6
commit bd4a3f4b94
1 changed files with 23 additions and 23 deletions

View File

@ -1811,10 +1811,10 @@
"// Only change code above this line", "// Only change code above this line",
"function fun2() {", "function fun2() {",
" var output = \"\";", " var output = \"\";",
" if(typeof myGlobal != \"undefined\") {", " if (typeof myGlobal != \"undefined\") {",
" output += \"myGlobal: \" + myGlobal;", " output += \"myGlobal: \" + myGlobal;",
" }", " }",
" if(typeof oopsGlobal != \"undefined\") {", " if (typeof oopsGlobal != \"undefined\") {",
" output += \" oopsGlobal: \" + oopsGlobal;", " output += \" oopsGlobal: \" + oopsGlobal;",
" }", " }",
" console.log(output);", " console.log(output);",
@ -2103,9 +2103,9 @@
"<code>If</code> statements are used to make decisions in code. The keyword <code>if</code> tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. These conditions are known as <code>Boolean</code> conditions because they may only be <code>true</code> or <code>false</code>.", "<code>If</code> statements are used to make decisions in code. The keyword <code>if</code> tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. These conditions are known as <code>Boolean</code> conditions because they may only be <code>true</code> or <code>false</code>.",
"When the condition evaluates to <code>true</code>, the program executes the statement inside the curly braces. When the Boolean condition evaluates to <code>false</code>, the statement inside the curly braces will not execute.", "When the condition evaluates to <code>true</code>, the program executes the statement inside the curly braces. When the Boolean condition evaluates to <code>false</code>, the statement inside the curly braces will not execute.",
"<strong>Pseudocode</strong>", "<strong>Pseudocode</strong>",
"<blockquote>if(<i>condition is true</i>) {<br> <i>statement is executed</i><br>}</blockquote>", "<blockquote>if (<i>condition is true</i>) {<br> <i>statement is executed</i><br>}</blockquote>",
"<strong>Example</strong>", "<strong>Example</strong>",
"<blockquote>function test (myCondition) {<br> if (myCondition) {<br> return \"It was true\";<br> }<br> return \"It was false\";<br>}<br>test(true); // returns \"It was true\"<br>test(false); // returns \"It was false\"</blockquote>", "<blockquote>function test (myCondition) {<br> if (myCondition) {<br> return \"It was true\";<br> }<br> return \"It was false\";<br>}<br>test(true); // returns \"It was true\"<br>test(false); // returns \"It was false\"</blockquote>",
"When <code>test</code> is called with a value of <code>true</code>, the <code>if</code> statement evaluates <code>myCondition</code> to see if it is <code>true</code> or not. Since it is <code>true</code>, the function returns <code>\"It was true\"</code>. When we call <code>test</code> with a value of <code>false</code>, <code>myCondition</code> is <em>not</em> <code>true</code> and the statement in the curly braces is not executed and the function returns <code>\"It was false\"</code>.", "When <code>test</code> is called with a value of <code>true</code>, the <code>if</code> statement evaluates <code>myCondition</code> to see if it is <code>true</code> or not. Since it is <code>true</code>, the function returns <code>\"It was true\"</code>. When we call <code>test</code> with a value of <code>false</code>, <code>myCondition</code> is <em>not</em> <code>true</code> and the statement in the curly braces is not executed and the function returns <code>\"It was false\"</code>.",
"<h4>Instructions</h4>", "<h4>Instructions</h4>",
"Create an <code>if</code> statement inside the function to return <code>\"That was true\"</code> if the parameter <code>wasThatTrue</code> is <code>true</code> and return <code>\"That was false\"</code> otherwise." "Create an <code>if</code> statement inside the function to return <code>\"That was true\"</code> if the parameter <code>wasThatTrue</code> is <code>true</code> and return <code>\"That was false\"</code> otherwise."
@ -2583,11 +2583,11 @@
" var result = \"\";", " var result = \"\";",
" // Only change code below this line", " // Only change code below this line",
"", "",
" if(val > 5) {", " if (val > 5) {",
" result = \"Bigger than 5\";", " result = \"Bigger than 5\";",
" }", " }",
" ", " ",
" if(val <= 5) {", " if (val <= 5) {",
" result = \"5 or Smaller\";", " result = \"5 or Smaller\";",
" }", " }",
" ", " ",
@ -2626,11 +2626,11 @@
"releasedOn": "January 1, 2016", "releasedOn": "January 1, 2016",
"challengeSeed": [ "challengeSeed": [
"function myTest(val) {", "function myTest(val) {",
" if(val > 10) {", " if (val > 10) {",
" return \"Greater than 10\";", " return \"Greater than 10\";",
" }", " }",
" ", " ",
" if(val < 5) {", " if (val < 5) {",
" return \"Smaller than 5\";", " return \"Smaller than 5\";",
" }", " }",
" ", " ",
@ -2674,9 +2674,9 @@
], ],
"challengeSeed": [ "challengeSeed": [
"function myTest(val) {", "function myTest(val) {",
" if(val < 10) {", " if (val < 10) {",
" return \"Less than 10\";", " return \"Less than 10\";",
" } else if(val < 5) {", " } else if (val < 5) {",
" return \"Less than 5\";", " return \"Less than 5\";",
" } else {", " } else {",
" return \"Greater than or equal to 10\";", " return \"Greater than or equal to 10\";",
@ -2702,7 +2702,7 @@
"title": "Chaining If Else Statements", "title": "Chaining If Else Statements",
"description": [ "description": [
"<code>if/else</code> statements can be chained together for complex logic. Here is <dfn>pseudocode</dfn> of multiple chained <code>if</code> / <code>else if</code> statements:", "<code>if/else</code> statements can be chained together for complex logic. Here is <dfn>pseudocode</dfn> of multiple chained <code>if</code> / <code>else if</code> statements:",
"<blockquote>if(<em>condition1</em>) {<br> <em>statement1</em><br>} else if (<em>condition2</em>) {<br> <em>statement2</em><br>} else if (<em>condition3</em>) {<br> <em>statement3</em><br>. . .<br>} else {<br> <em>statementN</em><br>}</blockquote>", "<blockquote>if (<em>condition1</em>) {<br> <em>statement1</em><br>} else if (<em>condition2</em>) {<br> <em>statement2</em><br>} else if (<em>condition3</em>) {<br> <em>statement3</em><br>. . .<br>} else {<br> <em>statementN</em><br>}</blockquote>",
"<h4>Instructions</h4>", "<h4>Instructions</h4>",
"Write chained <code>if</code>/<code>else if</code> statements to fulfill the following conditions:", "Write chained <code>if</code>/<code>else if</code> statements to fulfill the following conditions:",
"<code>num &lt; 5</code> - return \"Tiny\"<br><code>num &lt; 10</code> - return \"Small\"<br><code>num &lt; 15</code> - return \"Medium\"<br><code>num &lt; 20</code> - return \"Large\"<br><code>num >= 20</code> - return \"Huge\"" "<code>num &lt; 5</code> - return \"Tiny\"<br><code>num &lt; 10</code> - return \"Small\"<br><code>num &lt; 15</code> - return \"Medium\"<br><code>num &lt; 20</code> - return \"Large\"<br><code>num >= 20</code> - return \"Huge\""
@ -2915,7 +2915,7 @@
"title": "Replacing If Else Chains with Switch", "title": "Replacing If Else Chains with Switch",
"description": [ "description": [
"If you have many options to choose from, a <code>switch</code> statement can be easier to write than many chained <code>if</code>/<code>if else</code> statements. The following:", "If you have many options to choose from, a <code>switch</code> statement can be easier to write than many chained <code>if</code>/<code>if else</code> statements. The following:",
"<blockquote>if(val === 1) {<br> answer = \"a\";<br>} else if(val === 2) {<br> answer = \"b\";<br>} else {<br> answer = \"c\";<br>}</blockquote>", "<blockquote>if (val === 1) {<br> answer = \"a\";<br>} else if (val === 2) {<br> answer = \"b\";<br>} else {<br> answer = \"c\";<br>}</blockquote>",
"can be replaced with:", "can be replaced with:",
"<blockquote>switch (val) {<br> case 1:<br> answer = \"a\";<br> break;<br> case 2:<br> answer = \"b\";<br> break;<br> default:<br> answer = \"c\";<br>}</blockquote>", "<blockquote>switch (val) {<br> case 1:<br> answer = \"a\";<br> break;<br> case 2:<br> answer = \"b\";<br> break;<br> default:<br> answer = \"c\";<br>}</blockquote>",
"<h4>Instructions</h4>", "<h4>Instructions</h4>",
@ -2927,15 +2927,15 @@
" var answer = \"\";", " var answer = \"\";",
" // Only change code below this line", " // Only change code below this line",
" ", " ",
" if(val === \"bob\") {", " if (val === \"bob\") {",
" answer = \"Marley\";", " answer = \"Marley\";",
" } else if(val === 42) {", " } else if (val === 42) {",
" answer = \"The Answer\";", " answer = \"The Answer\";",
" } else if(val === 1) {", " } else if (val === 1) {",
" answer = \"There is no #1\";", " answer = \"There is no #1\";",
" } else if(val === 99) {", " } else if (val === 99) {",
" answer = \"Missed me by this much!\";", " answer = \"Missed me by this much!\";",
" } else if(val === 7) {", " } else if (val === 7) {",
" answer = \"Ate Nine\";", " answer = \"Ate Nine\";",
" }", " }",
" ", " ",
@ -2971,7 +2971,7 @@
"description": [ "description": [
"You may recall from <a href=\"waypoint-comparison-with-the-equality-operator\" target=\"_blank\">Comparison with the Equality Operator</a> that all comparison operators return a boolean <code>true</code> or <code>false</code> value.", "You may recall from <a href=\"waypoint-comparison-with-the-equality-operator\" target=\"_blank\">Comparison with the Equality Operator</a> that all comparison operators return a boolean <code>true</code> or <code>false</code> value.",
"A common <dfn>anti-pattern</dfn> is to use an <code>if/else</code> statement to do a comparison and then <code>return</code> <code>true</code>/<code>false</code>:", "A common <dfn>anti-pattern</dfn> is to use an <code>if/else</code> statement to do a comparison and then <code>return</code> <code>true</code>/<code>false</code>:",
"<blockquote>function isEqual(a,b) {<br> if(a === b) {<br> return true;<br> } else {<br> return false;<br> }<br>}</blockquote>", "<blockquote>function isEqual(a,b) {<br> if (a === b) {<br> return true;<br> } else {<br> return false;<br> }<br>}</blockquote>",
"Since <code>===</code> returns <code>true</code> or <code>false</code>, we can simply return the result of the comparison:", "Since <code>===</code> returns <code>true</code> or <code>false</code>, we can simply return the result of the comparison:",
"<blockquote>function isEqual(a,b) {<br> return a === b;<br>}</blockquote>", "<blockquote>function isEqual(a,b) {<br> return a === b;<br>}</blockquote>",
"<h4>Instructions</h4>", "<h4>Instructions</h4>",
@ -2981,7 +2981,7 @@
"challengeSeed": [ "challengeSeed": [
"function isLess(a, b) {", "function isLess(a, b) {",
" // Fix this code", " // Fix this code",
" if(a < b) {", " if (a < b) {",
" return true;", " return true;",
" } else {", " } else {",
" return false;", " return false;",
@ -4492,7 +4492,7 @@
"If they have, we should notify our user that they've won and we should return <code>null</code>.", "If they have, we should notify our user that they've won and we should return <code>null</code>.",
"<code>null</code> is a JavaScript data structure that means nothing.", "<code>null</code> is a JavaScript data structure that means nothing.",
"The user wins when all the three numbers match. Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.", "The user wins when all the three numbers match. Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.",
"<code>if(slotOne === slotTwo && slotTwo === slotThree){</code>", "<code>if (slotOne === slotTwo && slotTwo === slotThree){</code>",
"<code>&nbsp;&nbsp;return null;</code>", "<code>&nbsp;&nbsp;return null;</code>",
"<code>}</code>", "<code>}</code>",
"Also, we need to show the user that he has won the game when he gets the same number in all the slots.", "Also, we need to show the user that he has won the game when he gets the same number in all the slots.",
@ -4518,7 +4518,7 @@
" ", " ",
" // Only change code above this line.", " // Only change code above this line.",
" ", " ",
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);", " $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }", " }",
" ", " ",
@ -4683,7 +4683,7 @@
" return null;", " return null;",
" }", " }",
" ", " ",
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);", " $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }", " }",
" ", " ",
@ -4851,7 +4851,7 @@
" return null;", " return null;",
" }", " }",
" ", " ",
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);", " $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }", " }",
" ", " ",