In plain words
Every value has a type, such as a string (text), a number or a boolean (true or false), and the type decides what you can do with it.
Where you see it
Someone types 2 into QuickBite's quantity box, the code adds 1, and the cart shows 21. Form fields always hand your code text, so "2" + 1 glues the characters together instead of adding them.
What goes wrong
- Adding numbers that are secretly strings
Values from forms, URLs and some APIs arrive as text. The plus sign then joins them instead of adding, and totals grow extra digits.
"10" + 5 // "105" - Storing money as decimals
JavaScript can't hold some decimals exactly, so small errors creep into totals. Store prices as whole cents and divide only for display.
0.1 + 0.2 // 0.30000000000000004 - Saving "false" as text
The string "false" isn't empty, so code treats it as true. A setting stored this way can never be switched off.
if ("false") { /* this still runs */ }
What to tell your agent
Quick check
Sign in to earn +10 XP for itA Chirp post with 9 likes shows 91 after one more like. What happened?