Question 8
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("2" > "12", 2 > "12", "b" > "a");
- A false false true
- B true true true
- C true false true Correct
- D false true false
Correct Answer: Option C
Two strings compare character by character: "2" > "1", so "2" > "12". With one number, the string is converted: 2 > 12 is false.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!