Skip to content

Commit 8e8fb39

Browse files
add dir and ext
1 parent f5b9e81 commit 8e8fb39

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
1414
const base = filePath.slice(lastSlashIndex + 1);
1515
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 = ;
21-
const ext = ;
22-
23-
// https://www.google.com/search?q=slice+mdn
16+
const dir = filePath.slice(0,`${lastSlashIndex}`-1);
17+
const ext = filePath.slice(filePath.lastIndexOf("."));
18+
console.log(`The dir part of ${filePath} is ${dir}`);
19+
console.log(`The ext part of this URL is ${ext}`);

0 commit comments

Comments
 (0)