Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Going Further
Multiply and Divide
We can multiply with JavaScript. Try logging the following expressions:
3 * 4
2 * 2 * 2
We can also divide with JavaScript. Try the following lines:
4 / 2
21 / 3
66 / 3 / 2
Floating Point Numbers
What happens when we divide numbers that don't split evenly? Try it:
1 / 2
10 / 3
JavaScript can work with integers like 1
, 2
, and so on. These numbers have no decimal point.
JavaScript also understands numbers with decimals in them like 0.5
and 3.14
. These are called floating point numbers.
Some programming languages force you to label each number as an integer or floating point number. JavaScript does not. All numbers are numbers to JavaScript, and it is happy to mix and match them when doing math.
Learning Goals
I can multiply numbers in JavaScript
I can divide numbers in JavaScript
I know what a floating point number is
Code Editor
Click "Run Code" to execute your JavaScript in a secure sandbox and see the output below.
Console Output
0 output lines