From 295d280f5f4167277cd3390544acbb8d88bf0d5b Mon Sep 17 00:00:00 2001 From: lajacl Date: Mon, 28 Oct 2019 14:33:08 -0500 Subject: [PATCH 1/2] Add comparison operators exercises, closes #247 --- .../JavaScript_Basics/comparison_operators.md | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 docs/Exercise/JavaScript_Basics/comparison_operators.md diff --git a/docs/Exercise/JavaScript_Basics/comparison_operators.md b/docs/Exercise/JavaScript_Basics/comparison_operators.md new file mode 100644 index 0000000..5d79d3e --- /dev/null +++ b/docs/Exercise/JavaScript_Basics/comparison_operators.md @@ -0,0 +1,119 @@ +### Comparison Operators Exercises + + +**1. Choose the correct comparison operator to alert true, when x is greater than y.** + + x = 10; + y = 5; + alert(x :white_medium_square: y); + +
+SHOW ANSWER +> +
+ + +**2. Choose the correct comparison operator to alert true, when x is equal to y.** + + x = 10; + y = 10; + alert(x :white_medium_square: y); + +
+SHOW ANSWER +== OR === +
+ + +**3. Choose the correct comparison operator to alert true, when x is NOT equal to y.** + + x = 10; + y = 5; + alert(x :white_medium_square: y); + +
+SHOW ANSWER +!= OR !== +
+ + +**4. Choose the correct conditional (ternary) operator to alert "Too young" if age is less than 18, otherwise alert "Old enough".** + + var age = n; + var votingStatus = (age :white_medium_square: 18) :white_medium_square: "Too young" :white_medium_square: "Old enough"; + alert(votingStatus); + +
+SHOW ANSWER +< ? : +
+ + +**5. Will the output for this statement be true or false?** + + console.log(1 == 1); + +
+SHOW ANSWER +true +
+ + +**6. Will the output for this statement be true or false?** + + console.log(1 == "1"); + +
+SHOW ANSWER +true +
+ + +**7. Will the output for this statement be true or false?** + + console.log(1 === 1); + +
+SHOW ANSWER +true +
+ + +**8. Will the output for this statement be true or false?** + + console.log(1 === "1"); + +
+SHOW ANSWER +false +
+ + +**9. Will the output for this statement be true or false?** + + console.log(1 != "1"); + +
+SHOW ANSWER +false +
+ + +**10. Will the output for this statement be true or false?** + + console.log(1 !== "1"); + +
+SHOW ANSWER +true +
+ + +**11. What will the value of color be after the following statemnt is executed?** + + var color = 5 < 10 ? "red" : "blue"; + +
+SHOW ANSWER +"red" +
From 141acefa45d81ef3b2b52b3e7755470d217c8ac4 Mon Sep 17 00:00:00 2001 From: lajacl Date: Mon, 28 Oct 2019 17:55:21 -0500 Subject: [PATCH 2/2] Remove emoji that isn't properly displaying --- .../JavaScript_Basics/comparison_operators.md | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/Exercise/JavaScript_Basics/comparison_operators.md b/docs/Exercise/JavaScript_Basics/comparison_operators.md index 5d79d3e..ae629e9 100644 --- a/docs/Exercise/JavaScript_Basics/comparison_operators.md +++ b/docs/Exercise/JavaScript_Basics/comparison_operators.md @@ -1,11 +1,13 @@ ### Comparison Operators Exercises +***Note: __ = blank** -**1. Choose the correct comparison operator to alert true, when x is greater than y.** + +**1. Fill in the blank with the correct comparison operator to alert true, when x is greater than y.** x = 10; y = 5; - alert(x :white_medium_square: y); + alert(x __ y);
SHOW ANSWER @@ -13,11 +15,11 @@
-**2. Choose the correct comparison operator to alert true, when x is equal to y.** +**2. Fill in the blank with the correct comparison operator to alert true, when x is equal to y.** x = 10; y = 10; - alert(x :white_medium_square: y); + alert(x __ y);
SHOW ANSWER @@ -25,11 +27,11 @@
-**3. Choose the correct comparison operator to alert true, when x is NOT equal to y.** +**3. Fill in the blank with the correct comparison operator to alert true, when x is NOT equal to y.** x = 10; y = 5; - alert(x :white_medium_square: y); + alert(x __ y);
SHOW ANSWER @@ -37,10 +39,10 @@
-**4. Choose the correct conditional (ternary) operator to alert "Too young" if age is less than 18, otherwise alert "Old enough".** +**4. Fill in the three blanks with the correct conditional (ternary) operators to alert "Too young" if age is less than 18, otherwise alert "Old enough".** var age = n; - var votingStatus = (age :white_medium_square: 18) :white_medium_square: "Too young" :white_medium_square: "Old enough"; + var votingStatus = (age __ 18) __ "Too young" __ "Old enough"; alert(votingStatus);
@@ -109,7 +111,7 @@ true
-**11. What will the value of color be after the following statemnt is executed?** +**11. What will the value of the variable color be after the following statement is executed?** var color = 5 < 10 ? "red" : "blue";