Skip to content

Commit d868527

Browse files
committed
updated answers for 1-count.js and 3-path.js
1 parent 9bf4964 commit d868527

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ count = count + 1;
44

55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing
7-
// line 3 returns the incurmented value of count after adding 1 to it and assigns this new value back to count
7+
// line 3 is an assignment which returns the incurmented value of count after adding 1 to it.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
14-
const base = filePath.slice(lastSlashIndex + 1);
15-
console.log (the base part of ${filePath} is ${base});
14+
const base = filePath.slice(lastSlashIndex + 1); // file.txt
15+
console.log (`the base part of ${filePath} is ${base}`);
1616

1717
// Create a variable to store the dir part of the filePath variable.
1818
// Create a variable to store the ext part of the variable.
1919

20-
const dir = filePath.slice(lastSlashIndex+1)
21-
const ext = filePath.slice(lastDotIndexOf(".") +1);
20+
const dir = filePath.slice(0, lastSlashIndex)
21+
const ext = filePath.slice(filePath.lastIndexOf("."));
2222

23-
console.log (dir)
23+
console.log (dir, ext)
2424
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,4 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1010

1111

12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
2412
console.log(num);

0 commit comments

Comments
 (0)