Question 16
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log(10 / 4);
console.log(10 / 0);
console.log(-10 / 0);
- A 2.5 Infinity -Infinity Correct
- B 2 Error Error
- C 2.5 NaN NaN
- D 2 Infinity -Infinity
Correct Answer: Option A
All numbers are 64-bit floating point, so 10 / 4 is 2.5 (no integer division). Dividing a non-zero number by 0 gives Infinity or -Infinity; only 0 / 0 is NaN.
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!