Skip to content

Commit d845bba

Browse files
committed
Create variables to store the dir and ext parts of the filepath variable
1 parent cdfcef0 commit d845bba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

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

1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313
const lastSlashIndex = filePath.lastIndexOf("/");
14+
console.log(lastSlashIndex);
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+
console.log(dir);
23+
const ext = filePath.slice(lastSlashIndex + 1) ;
24+
console.log(ext);
2225

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

0 commit comments

Comments
 (0)