diff --git a/docs/Exercise/JavaScript_Basics/comparison_operators.md b/docs/Exercise/JavaScript_Basics/comparison_operators.md new file mode 100644 index 0000000..ae629e9 --- /dev/null +++ b/docs/Exercise/JavaScript_Basics/comparison_operators.md @@ -0,0 +1,121 @@ +### Comparison Operators Exercises + +***Note: __ = blank** + + +**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 __ y); + +
+SHOW ANSWER +> +
+ + +**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 __ y); + +
+SHOW ANSWER +== OR === +
+ + +**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 __ y); + +
+SHOW ANSWER +!= OR !== +
+ + +**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 __ 18) __ "Too young" __ "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 the variable color be after the following statement is executed?** + + var color = 5 < 10 ? "red" : "blue"; + +
+SHOW ANSWER +"red" +