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,13 +3,14 @@ const maximum = 100;
33
44const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
55
6- //1.num represents a number which is an Integer.
6+ //1.num represents a number which is an Integer that is greater or equal to 1.
7+ // That is because of the value of the minimum is 1.
78//2.lets start by (maximum-minimum +1) which the output is 100.
89//3.math.random()*100 returns random number between 0 and 100, what actually
910// happens is that math.randum gives out random number from 0 to 1 which 1 is
1011// not included and in this case, multiply the output by 100.
1112//4.math.floor() gives out the largest intiger which is less than or equal to
12- // the given number,which is decimal, which means it drops all the decimal. forexample if
13+ // the given number,which is decimal, which means it drops all the decimal. forexample if
1314// the output is 69.5, it compares 69 with 69.5.The output will be 69 which is the largest Integer.
1415//5.at the end we add 1 which is the minimum.
1516console . log ( num ) ;
You can’t perform that action at this time.
0 commit comments