Skip to content

Commit 4431ccd

Browse files
committed
completed second exercise of key exercises
1 parent d87465a commit 4431ccd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

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

1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
14+
const lastDotIndex = filePath.lastIndexOf(".");
1415
const base = filePath.slice(lastSlashIndex + 1);
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);
2223

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

0 commit comments

Comments
 (0)