Strings, Numbers and Booleans
In short: every value is text, a number or a yes/no, and JavaScript tells
them apart by how the value is written, not by what it looks like. Quotes at
the two edges make a string, even if the quoted text is all digits. Bare
digits with no quotes make a number. The bare words true/false make a
boolean. Get this wrong and "214" behaves nothing like 214.

A song length typed into a form
Every value a listener types into a web form arrives as a string, even a length like 214 seconds. Add 6 seconds of fade-out the careless way and you get a mess:
"214" + 6 joins text because one side is a string: "2146". Converting
first with Number() gives the number you actually wanted, 220. The bug is
never in the maths — it's in trusting that a typed value is already a number.
Averaging two star ratings
Numbers cover both whole numbers and decimals with one type, and that type is a 64-bit floating-point value under the hood. Most of the time that's invisible; sometimes it bites:
4.5 + 4.2 is 8.7, fine — but 0.1 + 0.2 is 0.30000000000000004, not
0.3. Some decimals simply cannot be stored exactly in binary. Never compare
two decimals with ===; compare the difference instead, or round first with
.toFixed(2).
A "logged in" flag that never logs anyone out
A boolean is exactly true or false, nothing else, and it drives every
if. The trap is a look-alike string:
loggedInText holds the five-letter string "false", and every non-empty
string is truthy, so the if runs. Only the real boolean false skips it.
Storing flags as text and forgetting to convert them back is one of the most
common bugs in JavaScript.
214No quotes, digits inside: a number.
Quick practice
What type is the value "42"?
What does console.log("Song: " + "Blue Hour".length) print?
What does 0.1 + 0.2 === 0.3 evaluate to?
A settings object stores darkMode: "false" (a string). What happens in if (darkMode) { enableDark(); }?
