Skip to main content
PProfileMatch
← Path

JavaScript Fundamentals · JavaScript Variables, Data Types and Functions Explained

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Bike shop: reading the price tags

Trick to keep in mind+3 XP

+ is glue when text is nearby; - is always maths

The + operator is overloaded: if either side is a string it joins text, converting the other side. Subtraction, multiplication and division have no text meaning, so they always convert both sides to numbers first. Form values arrive as strings, so convert with Number() before adding.

console.log("7" + 1, "7" - 1, "7" * "2");

Read it once, then a question tests whether the trick stuck.