Skip to content

Commit 7b47ad2

Browse files
committed
Modified the exercises
1 parent 61a941a commit 7b47ad2

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

Sprint-1/1-key-exercises/1-count.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
let 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

Sprint-1/1-key-exercises/3-paths.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
1414
const base = filePath.slice(lastSlashIndex + 1);
1515
console.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

2020
const 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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)