Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

JavaScript Can't Do Basic Math?! 🀯 JS Quiz #1

Video information, playback and saved actions.

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
Β Β Β Β Β Β 
Videos related to "JavaScript Can't Do Basic Math?! 🀯 JS Quiz #1"