Numbers Review

It is important to reinforce that in JavaScript, all numeric values are treated uniformly as the number type. Unlike other languages that strictly separate integers and floating-point numbers into distinct memory structures, JavaScript simplifies arithmetic under a single umbrella.

Common Operations

Here is a quick reference for standard arithmetic evaluation:

Addition

2 + 1;
// 3

Subtraction

2 - 1;
// 1

Multiplication

2 * 2;
// 4

Division

3 / 2;
// 1.5 
// Note: Even though the inputs are whole numbers, the output is a decimal, but it remains the same underlying "number" type.

Practical Example

Calculating costs is straightforward, regardless of whether the totals are in the thousands or include fractional currency.

const costPerItem = 0.05;
const volume = 1000;

// Both are 'number' types, so they multiply directly
const totalCost = costPerItem * volume;

console.log("Total cost: $", totalCost); // Total cost: $ 50