const myInt = 5;
const myFloat = 6.667;
myInt;
myFloat;Basic math in JavaScript — numbers and operators
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
typeof myInt;
typeof myFloat;const lotsOfDecimal = 1.7665849587;
lotsOfDecimal;
const twoDecimalPlaces = lotsOfDecimal.toFixed(2);
twoDecimalPlaces;let myNumber = "74";
myNumber += 3;typeof myNumber;let myNumber = "74";
myNumber = Number(myNumber) + 3; 10 + 7;
9 * 8;
60 % 3; const num1 = 10;
const num2 = 50;
9 * num1;
num1 ** 3;
num2 / num1; 5 + 10 * 3;
(num2 % 9) * num1;
num2 + num1 / 8 + 2;num2 + num1 / 8 + 2;(num2 + num1) / (8 + 2);2 + 3 ** 2;4 + 2 ** 3;
(4 + 2) ** 3;guessCount++;