File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
88// It will help to think about the order in which expressions are evaluated
99// Try logging the value of num and running the program several times to build an idea of what the program is doing
1010
11- // math.floor will make the number as a whole and remove any decimals or more likely to round the the nearest whole number
12- // math.random returns a random number in [0,1)
11+ // math.floor round down to the nearest whole number e.g Math.floor(4.4) or Math.floor(4.8) will return 4
12+ // math.ceil round up to the nearest whole number e.g Math.ceil(4.8) and Math.ceil(4.4) will return 5
1313// (maximum - minimum + 1) provide a range of generated random number
1414// num is a random whole number [1,100]
15- console . log ( num ) ;
15+
16+ console . log ( Math . floor ( 4.8 ) )
1617console . log ( Math . floor ( 4.4 ) )
18+ console . log ( Math . ceil ( 4.8 ) )
1719console . log ( Math . ceil ( 4.4 ) )
You can’t perform that action at this time.
0 commit comments