File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11let count = 0 ;
22
3- count = count + 1 ;
3+ // count = count + 1;
4+ // count += 1;
5+ count ++ ;
6+
7+ console . log ( count ) ; // 1
48
59// Line 1 is a variable declaration, creating the count variable with an initial value of 0
610// Describe what line 3 is doing, in particular focus on what = is doing
Original file line number Diff line number Diff line change 99
1010// (All spaces in the "" line should be ignored. They are purely for formatting.)
1111
12- const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt" ;
12+ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt.json " ;
1313const lastSlashIndex = filePath . lastIndexOf ( "/" ) ;
1414const base = filePath . slice ( lastSlashIndex + 1 ) ;
1515console . log ( `The base part of ${ filePath } is ${ base } ` ) ;
@@ -18,6 +18,9 @@ console.log(`The base part of ${filePath} is ${base}`);
1818// Create a variable to store the ext part of the variable
1919
2020const dir = filePath . slice ( 1 , lastSlashIndex ) ;
21- const ext = filePath . slice ( lastSlashIndex + 5 ) ;
2221
23- // https://www.google.com/search?q=slice+mdn
22+ // const ext = filePath.slice(lastSlashIndex + 5);
23+
24+ const ext = filePath . split ( '/' ) . pop ( ) . split ( '.' ) . pop ( ) ;
25+
26+ // Although it is a lengthy solution but it works
Original file line number Diff line number Diff line change @@ -10,6 +10,6 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010
1111// Math.random() * (maximum - minimum + 1) + minimum;
1212// Returns a random number between 1 and 100.
13- // The returned value is bigger than (and may possibly equal) 1 and is less than (and may possibly equal) 100 ;
13+ // The returned value is between 1 and 100 (both included) ;
1414
1515// Lastly, Math.floor() rounds down and returns the largest integer between 1 and 100
You can’t perform that action at this time.
0 commit comments