-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy path4-random.js
More file actions
16 lines (12 loc) · 797 Bytes
/
4-random.js
File metadata and controls
16 lines (12 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const minimum = 1;
const maximum = 100;
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// In this exercise, you will need to work out what num represents?
// Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing
// math.floor will make the number as a whole and remove any decimals or more likely to round the the nearest whole number
// math.random will generate a random number between (0,1) inclusivly
// (maximum - minimum + 1) provide a range of generated random number
// num is a random whole number (1,100) inclusivly
console.log(num);