Skip to content

Commit deb7eef

Browse files
authored
Extracted directory and extension parts from filePath.
1 parent 672d4d6 commit deb7eef

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
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+
1516
console.log(`The base part of ${filePath} is ${base}`);
1617

1718
// Create a variable to store the dir part of the filePath variable
1819
// Create a variable to store the ext part of the variable
1920

20-
const dir = ;
21-
const ext = ;
21+
const dir = filePath.slice(0,lastSlashIndex);
22+
const ext = filePath.slice(lastDotIndex+1);
2223

23-
// https://www.google.com/search?q=slice+mdn
24+
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)