×

javascript · level 1 · unit 3 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Quotes turn a into text.

JavaScript sorts values into kinds. Text in quotes is a string. A value like 12, with no quotes, is a number. Same digits, different kind, and JavaScript treats them very differently.

Picture a front door with 12 painted on it, and a box of 12 eggs. The door number is a label you read, like "12". The eggs are an amount you can count and add, like 12.

With numbers, + adds, so 5 + 3 is 8. With strings, + joins, so "5" + "3" is "53". Not sure which kind you have? Put in front and it tells you.

console.log(typeof "12");
console.log(typeof 12);
console.log(5 + 3);
console.log("5" + "3");

If + meets a string and a number, it joins them as text.