Concept Flow - Arithmetic operators
Start
Evaluate operands
Apply operator (+, -, *, /, %)
Calculate result
Return or store result
End
This flow shows how arithmetic operators take values, perform calculations, and produce a result.
let a = 10; let b = 3; let sum = a + b; let diff = a - b; let prod = a * b; let div = a / b;
| Step | Expression | Operands | Operation | Result |
|---|---|---|---|---|
| 1 | a = 10 | - | - | a = 10 |
| 2 | b = 3 | - | - | b = 3 |
| 3 | sum = a + b | 10, 3 | Addition | 13 |
| 4 | diff = a - b | 10, 3 | Subtraction | 7 |
| 5 | prod = a * b | 10, 3 | Multiplication | 30 |
| 6 | div = a / b | 10, 3 | Division | 3.3333333333333335 |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | After Step 5 | After Step 6 |
|---|---|---|---|---|---|---|---|
| a | undefined | 10 | 10 | 10 | 10 | 10 | 10 |
| b | undefined | undefined | 3 | 3 | 3 | 3 | 3 |
| sum | undefined | undefined | undefined | 13 | 13 | 13 | 13 |
| diff | undefined | undefined | undefined | undefined | 7 | 7 | 7 |
| prod | undefined | undefined | undefined | undefined | undefined | 30 | 30 |
| div | undefined | undefined | undefined | undefined | undefined | undefined | 3.3333333333333335 |
Arithmetic operators perform math on numbers: + adds, - subtracts, * multiplies, / divides, % gives remainder. They return a new value without changing original variables.
% returns the remainder after division of two numbers./ is division, ** is power, and * is multiplication, so they don't give remainder.** to calculate powers, like 5 ** 3 means 5 to the power 3.^ is bitwise XOR, ^^ is invalid syntax, and pow() is not a built-in function in JavaScript.console.log(10 % 4);
let result = 5 **; console.log(result);
** needs two operands, like 5 ** 2. Here, the right operand is missing.% gives the leftover amount, so 100 % 6 is correct.Pass the test and this pattern moves unknown