File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313const lastSlashIndex = filePath . lastIndexOf ( "/" ) ;
1414const base = filePath . slice ( lastSlashIndex + 1 ) ;
1515console . log ( `The base part of ${ filePath } is ${ base } ` ) ;
16- const dir = filePath . slice ( 0 , `${ lastSlashIndex } ` - 1 ) ;
16+ const dir = filePath . slice ( 0 , `${ lastSlashIndex } ` ) ;
1717const ext = filePath . slice ( filePath . lastIndexOf ( "." ) ) ;
1818console . log ( `The dir part of ${ filePath } is ${ dir } ` ) ;
19- console . log ( `The ext part of this URL is ${ ext } ` ) ;
19+ console . log ( `The ext part of this URL is ${ ext } ` ) ;
Original file line number Diff line number Diff line change 11const minimum = 1 ;
22const maximum = 100 ;
3-
43const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
54console . log ( `${ num } ` ) ;
65
76//num represents a random whole number between 1 and 100,
8- //first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100
7+ //first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100
98// math.random return number between 0 and 1
10- // math.random() * 100 give us a integer number
9+ // math.random() * 100 give us a decimal number
1110// math.floor round down the number
12- // add 1 to the result
13- //for example math.floor((0.783 *100))=78 + 1 = 79
11+ // add 1 to the result
12+ //for example math.floor((0.783 *100))=78 + 1 = 79
You can’t perform that action at this time.
0 commit comments