Lesson 2 of 5 · 8 minutes

Text and numbers are different

The kind of a value is called its type.

A number can be used for maths, like 5. A string is text inside quotes, like "5". They look similar but act differently.

With numbers, + adds: 5 + 5 gives 10. With strings, it joins: "5" + "5" gives "55". Quotes tell the computer “this is text.”

Two boxes compare the number 5 with the string quote 5 quote

They look alike. They do not act alike.

Predict first: what will each line print?

Loading the editor…

Quick check

What does "5" + "5" produce?

Choose one answer.

What marks a value as text?

Choose one answer.

You can now tell text from numbers — and you know why + does not always mean add.