File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ const maximum = 100;
33
44const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
55
6- //num represents a number
7- //lets start by (maximum-minimum +1) which the output is 100.
8- //math.random()*100 returns random number between 0 and 100
9- //math.floor()it rounds a number to thier nearest integer,
10- //at the end we add 1.
6+ //1.num represents a number which is an Integer.
7+ //2.lets start by (maximum-minimum +1) which the output is 100.
8+ //3.math.random()*100 returns random number between 0 and 100, what actually
9+ // happens is that math.randum gives out random number from 0 to 1 which 1 is
10+ // not included and in this case, multiply the out put by 100.
11+ //4.math.floor()it rounds a number to thier nearest integer, which means it drops all the decimal.
12+ //5.at the end we add 1 which is the minimum.
1113console . log ( num ) ;
You can’t perform that action at this time.
0 commit comments