Skip to content

Commit b865cde

Browse files
committed
answered 1-key-exercises 3-path
1 parent 23d0e93 commit b865cde

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
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);
14+
const base = filePath.slice(lastSlashIndex);
1515
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

2020
const dir = filePath.slice(0, lastSlashIndex);
21-
const ext = filePath.slice();
21+
const ext = base.slice(base.lastIndexOf(".") + 1);
22+
23+
console.log(ext)
2224

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

0 commit comments

Comments
 (0)