×

typescript · 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 number into text.

12 is a number. "12" in quotes is a string that happens to contain digits. They look alike, but TypeScript treats them very differently.

With numbers, + adds: 5 + 3 is 8. With strings, + joins: "5" + "3" is "53". Mix one of each and it still joins, so "5" + 3 is "53" too.

Not sure which you have? tells you the type of a value, as a string like "number". And the checker will never let a string slip into a number box.

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

A phone number is a string, because you never do maths with it.