JavaScript code: console.log(parseInt("10.5") + parseInt("5.7") + "2"); What…
2025
JavaScript code:
console.log(parseInt("10.5") + parseInt("5.7") + "2");
What is the output?
- A.
152
- B.
17.7
- C.
16.2
- D.
152.7
- E.
NaN
Attempted by 18 students.
Show answer & explanation
Correct answer: A
Correct answer: 152.
parseInt("10.5") gives 10 and parseInt("5.7") gives 5. The numeric addition happens first: 10 + 5 = 15. Then 15 + "2" performs string concatenation, producing "152".