Skip to content

Commit c253857

Browse files
authored
Refactor random number generation and comments
Removed redundant comments and added a console log for num.
1 parent 1cf24f7 commit c253857

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎Sprint-2/1-key-exercises/4-random.js‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ const minimum = 1;
22
const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5-
5+
console.log(num);
66
// In this exercise, you will need to work out what num represents?
77
// Try breaking down the expression and using documentation to explain what it means
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+
//First, const minimum and const maximum are variables
12+
// = is the assignment operator
13+
// what comes after = is what the variable will store
14+
// Math.floor is a method, and here we are telling it that its argument is to use the random method
15+
// and multiply the result before rounding with the maximum and minimum variables we created
16+
// * is a multiplication operator
17+
//To understand what is going on, we need to understand what the floor and random methods do
18+
//Math.floor (rounds down) and then pass it to Math.floor
19+
//We are asking the program to round whatever result we have to the nearest whole number
1120

12-
//here starts my learning
13-
14-
// first const minimun, const maximum are the variables
15-
// = the assignmen operator
16-
// what comes after = is what the variable will store
17-
// Math.floor is a method and here we are telling it that its argument is to use the random method
18-
// and multiply the result before rounding with the maximum and minimum variables we created
19-
// * is a multiplication operator
20-
// to understand what is going on we need to understand what the floor and random methods do
21-
//Math.floor (rounds down to the nearest whole number) and than pass it to Math.floor
22-
// we are asking the program to round whatever result we have to the nearest whole number
21+
//done

0 commit comments

Comments
 (0)