JavaScript Can't Do Basic Math?! π€― JS Quiz #1
Description: "5" + 2 = "52" but "5" - 2 = 3?! π€―
JavaScript isn't broken. It's type coercion.
β Plus with a string β joins them ("52")
β Minus only works with numbers β converts "5" to 5 (3)
β Want real math? Use Number("5") + 2 β 7
π§ YOUR TURN: What is true + true?
A) 2
B) "truetrue"
C) true
D) NaN
Answer in the comments π
This is JS Quiz #1. Follow for daily JavaScript quizzes!
#javascript #shorts #coding #programming #webdevelopment #js #jsquiz #frontend #learnjavascript #codingtipsΒ Close description
JavaScript isn't broken. It's type coercion.
β Plus with a string β joins them ("52")
β Minus only works with numbers β converts "5" to 5 (3)
β Want real math? Use Number("5") + 2 β 7
π§ YOUR TURN: What is true + true?
A) 2
B) "truetrue"
C) true
D) NaN
Answer in the comments π
This is JS Quiz #1. Follow for daily JavaScript quizzes!
#javascript #shorts #coding #programming #webdevelopment #js #jsquiz #frontend #learnjavascript #codingtipsΒ Close description




