Skip to content

Commit fc4edcc

Browse files
key exercises (3-paths solution)
1 parent 43a7404 commit fc4edcc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
1414
const base = filePath.slice(lastSlashIndex + 1);
15+
const dir = filePath.slice(0, lastSlashIndex);
16+
const ext = filePath.slice(lastSlashIndex + 5);
17+
1518
console.log(`The base part of ${filePath} is ${base}`);
19+
console.log(`The dir part of ${filePath} is ${dir}`);
20+
console.log(`The ext part of ${filePath} is ${ext}`);
21+
1622

1723
// Create a variable to store the dir part of the filePath variable
1824
// Create a variable to store the ext part of the variable
1925

20-
const dir = ;
21-
const ext = ;
26+
2227

2328
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)