Home

Arithmetic operators

Open the developer console to see the result

Arithmetic operators:
**************************
x = 10
y = 3
x + y = 13
x - y = 7
x * y = 30
x / y = 3.3333333333333335
x % y = 1
x ** y = 1000
Post increment (x++):
***************************************
x = 10       x starts at 10
x++ = 10     x has not incremented yet!
x = 11
Pre increment (++y):
***************************************
y = 3       y starts at 3
++y = 4     y has has already been incremented
y = 4

let n=10,e=3;const t=`Arithmetic operators:\n**************************\nx = ${n}\ny = ${e}\nx + y = ${n+e}\nx - y = ${n-e}\nx * y = ${n*e}\nx / y = ${n/e}\nx % y = ${n%e}\nx ** y = ${n**e}\n`;console.log(t),document.querySelector("pre").innerHTML=t;const o=`Post increment (x++):\n***************************************\nx = ${n}       x starts at 10\nx++ = ${n++}     x has not incremented yet!\nx = ${n}\n`;console.log(o),document.querySelector("pre:nth-of-type(2)").innerHTML=o;const r=`Pre increment (++y):\n***************************************\ny = ${e}       y starts at 3\n++y = ${++e}     y has has already been incremented\ny = ${e}\n`;console.log(r),document.querySelector("pre:nth-of-type(3)").innerHTML=r;
//# sourceMappingURL=arithmetic.js.map