Let's begin by exploring how JavaScript handles numbers that aren't whole numbers.
Numbers can have decimal points, like 3.14
or 9.99
. In programming, these are often called floating-point numbers, or "floats" for short.
Engagement Message
Have you worked with decimals before?
In JavaScript, there is only one number
data type, which is used for both whole numbers (integers) and numbers with decimals (floats).
Examples include 1.0
, 3.14159
, or -2.5
.
Engagement Message
Do you think the value 100
is the same number
type as 100.0
in JavaScript?
You can store decimal numbers in variables just like other types:
You can also perform standard math operations (+
, -
, *
, ) with them.
