JavaScript Arithmetic
JavaScript Arithmetic Operators
Arithmetic operators perform arithmetic on numbers (literals or variables).
| Operator | Description |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| ** | Exponentiation (ES2016) |
| / | Division |
| % | Modulus (Remainder) |
| ++ | Increment |
| -- | Decrement |
Arithmetic Operations
A typical arithmetic operation operates on two numbers.
The two numbers can be literals:
Example
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Arithmetic</h2>
<p>A typical arithmetic operation takes two numbers and produces a new number.</p>
<p id="demo"></p>
<script>
let x = 100 + 50;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
No comments:
Post a Comment