42
64-bit float

In JavaScript, all numbers are formatted as floating points.
Integers (10) and decimals (10.5) are the same type.

let integer = 10;
let decimal = 10.5;

console.log(typeof integer); // "number"

Number Fundamentals

In JavaScript, numbers are floating-point by default. This means 10 and 10.5 are the same type. Computers use binary 0s and 1s, so be careful: 0.1 + 0.2 isn't exactly 0.3!

Shortcuts (+=, ++)

Programmers love shortcuts. Instead of 'score = score + 1', we can write 'score++'. To add 10, 'score += 10'. It's cleaner and faster to type.

The Math Object

JavaScript comes with a built-in 'Math' object. It's like a scientific calculator. 'Math.random()' gives a random decimal. 'Math.round()' rounds to the nearest integer.

Weird Numbers (NaN, Infinity)

Sometimes math breaks. If you divide by zero, you get Infinity. If you try to multiply words, you get NaN (Not a Number). Checking for these prevents bugs!

Calculated!

You've mastered JavaScript arithmetic.
Now let's explore text with Strings.

AlgoAnimator: Interactive Data Structures