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 + t ...ย Close description
ย ย ย ย ย ย 
Videos related to "JavaScript Can't Do Basic Math?! ๐Ÿคฏ JS Quiz #1"