diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json
index 93270592f1b..e008affe6c3 100644
--- a/challenges/01-front-end-development-certification/basic-javascript.json
+++ b/challenges/01-front-end-development-certification/basic-javascript.json
@@ -1811,10 +1811,10 @@
"// Only change code above this line",
"function fun2() {",
" var output = \"\";",
- " if(typeof myGlobal != \"undefined\") {",
+ " if (typeof myGlobal != \"undefined\") {",
" output += \"myGlobal: \" + myGlobal;",
" }",
- " if(typeof oopsGlobal != \"undefined\") {",
+ " if (typeof oopsGlobal != \"undefined\") {",
" output += \" oopsGlobal: \" + oopsGlobal;",
" }",
" console.log(output);",
@@ -2103,9 +2103,9 @@
"If
statements are used to make decisions in code. The keyword if
tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. These conditions are known as Boolean
conditions because they may only be true
or false
.",
"When the condition evaluates to true
, the program executes the statement inside the curly braces. When the Boolean condition evaluates to false
, the statement inside the curly braces will not execute.",
"Pseudocode",
- "
if(condition is true) {", + "
statement is executed
}
if (condition is true) {", "Example", - "
statement is executed
}
function test (myCondition) {", + "
if (myCondition) {
return \"It was true\";
}
return \"It was false\";
}
test(true); // returns \"It was true\"
test(false); // returns \"It was false\"
function test (myCondition) {", "When
if (myCondition) {
return \"It was true\";
}
return \"It was false\";
}
test(true); // returns \"It was true\"
test(false); // returns \"It was false\"
test
is called with a value of true
, the if
statement evaluates myCondition
to see if it is true
or not. Since it is true
, the function returns \"It was true\"
. When we call test
with a value of false
, myCondition
is not true
and the statement in the curly braces is not executed and the function returns \"It was false\"
.",
"if
statement inside the function to return \"That was true\"
if the parameter wasThatTrue
is true
and return \"That was false\"
otherwise."
@@ -2583,11 +2583,11 @@
" var result = \"\";",
" // Only change code below this line",
"",
- " if(val > 5) {",
+ " if (val > 5) {",
" result = \"Bigger than 5\";",
" }",
" ",
- " if(val <= 5) {",
+ " if (val <= 5) {",
" result = \"5 or Smaller\";",
" }",
" ",
@@ -2626,11 +2626,11 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"function myTest(val) {",
- " if(val > 10) {",
+ " if (val > 10) {",
" return \"Greater than 10\";",
" }",
" ",
- " if(val < 5) {",
+ " if (val < 5) {",
" return \"Smaller than 5\";",
" }",
" ",
@@ -2674,9 +2674,9 @@
],
"challengeSeed": [
"function myTest(val) {",
- " if(val < 10) {",
+ " if (val < 10) {",
" return \"Less than 10\";",
- " } else if(val < 5) {",
+ " } else if (val < 5) {",
" return \"Less than 5\";",
" } else {",
" return \"Greater than or equal to 10\";",
@@ -2702,7 +2702,7 @@
"title": "Chaining If Else Statements",
"description": [
"if/else
statements can be chained together for complex logic. Here is pseudocode of multiple chained if
/ else if
statements:",
- "if(condition1) {", + "
statement1
} else if (condition2) {
statement2
} else if (condition3) {
statement3
. . .
} else {
statementN
}
if (condition1) {", "
statement1
} else if (condition2) {
statement2
} else if (condition3) {
statement3
. . .
} else {
statementN
}
if
/else if
statements to fulfill the following conditions:",
"num < 5
- return \"Tiny\"num < 10
- return \"Small\"num < 15
- return \"Medium\"num < 20
- return \"Large\"num >= 20
- return \"Huge\""
@@ -2915,7 +2915,7 @@
"title": "Replacing If Else Chains with Switch",
"description": [
"If you have many options to choose from, a switch
statement can be easier to write than many chained if
/if else
statements. The following:",
- "if(val === 1) {", + "
answer = \"a\";
} else if(val === 2) {
answer = \"b\";
} else {
answer = \"c\";
}
if (val === 1) {", "can be replaced with:", "
answer = \"a\";
} else if (val === 2) {
answer = \"b\";
} else {
answer = \"c\";
}
switch (val) {", "
case 1:
answer = \"a\";
break;
case 2:
answer = \"b\";
break;
default:
answer = \"c\";
}
true
or false
value.",
"A common anti-pattern is to use an if/else
statement to do a comparison and then return
true
/false
:",
- "function isEqual(a,b) {", + "
if(a === b) {
return true;
} else {
return false;
}
}
function isEqual(a,b) {", "Since
if (a === b) {
return true;
} else {
return false;
}
}
===
returns true
or false
, we can simply return the result of the comparison:",
"function isEqual(a,b) {", "
return a === b;
}
null
.",
"null
is a JavaScript data structure that means nothing.",
"The user wins when all the three numbers match. Let's create an if statement
with multiple conditions in order to check whether all numbers are equal.",
- "if(slotOne === slotTwo && slotTwo === slotThree){
",
+ "if (slotOne === slotTwo && slotTwo === slotThree){
",
" return null;
",
"}
",
"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.",
" ",
- " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
+ " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }",
" ",
@@ -4683,7 +4683,7 @@
" return null;",
" }",
" ",
- " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
+ " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }",
" ",
@@ -4851,7 +4851,7 @@
" return null;",
" }",
" ",
- " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
+ " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
" }",
" ",