×

javascript · level 1 · unit 3 · lesson 2

  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

JavaScript is a calculator that never gets tired.

Each maths symbol is an . + adds, - takes away, * multiplies (a star, not an x) and / divides. Numbers can have a decimal point too, like 2.5.

Dividing can leave bits, so 7 / 2 gives 3.5. Sharing 7 slices of pizza between 2 friends? Each gets 3 whole slices, and 7 % 2 gives the : the 1 slice left over.

Like on paper, * and / happen before + and -. Brackets beat them all, so wrap the part you want worked out first.

console.log(7 / 2);
console.log(7 % 2);
console.log(2 + 3 * 4);
console.log((2 + 3) * 4);

Here % has nothing to do with percentages: it finds what is left over.