JavaScript Numbers
number is a data type in JavaScript that represents numeric values.
2 June, 2024
99
99
1
Contributors
Numbers in JavaScript are used to do all kinds of calculations and represent numeric values
- we can use numbers to do things like addition, subtraction, multiplication, and division.
we can write numbers in JavaScript without quotes " " or ' '
let myAge = 22; //integers
let myHeight = 5.8 // decimale
There are two types of numbers
- floats
- integers
Basic math with numbers using operator ( + , - , / , * )
let addTwoNumbers = 2 + 1 //addition operator +
let subtractionNumbers = 2 - 3 //subtraction oprator -
let multiplyNumbers = 2 * 3 // Multiplication oparetor *
let divisionNumbers = 6 / 2 //Division oparetor /
let remainderNumbers = 6 /2
math using numbers and variables
let x = 12
let y = 2
let sum = x+y
consloe.log(sum)
Numbers are a fundamental part of programming, and with these basics, we can do maths or create programs etc