There was an error while loading. Please reload this page.
1 parent 23d0e93 commit b865cdeCopy full SHA for b865cde
1 file changed
Sprint-2/1-key-exercises/3-paths.js
@@ -11,13 +11,15 @@
11
12
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
13
const lastSlashIndex = filePath.lastIndexOf("/");
14
-const base = filePath.slice(lastSlashIndex + 1);
+const base = filePath.slice(lastSlashIndex);
15
console.log(`The base part of ${filePath} is ${base}`);
16
17
// Create a variable to store the dir part of the filePath variable
18
// Create a variable to store the ext part of the variable
19
20
const dir = filePath.slice(0, lastSlashIndex);
21
-const ext = filePath.slice();
+const ext = base.slice(base.lastIndexOf(".") + 1);
22
+
23
+console.log(ext)
24
25
// https://www.google.com/search?q=slice+mdn
0 commit comments