Skip to content

Commit ad07e16

Browse files
committed
Directory and extension part of a file path
1 parent d88693e commit ad07e16

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ const base = filePath.slice(lastSlashIndex + 1);
1515
console.log(`The base part of ${filePath} is ${base}`);
1616

1717
// Create a variable to store the dir part of the filePath variable
18+
const dir = filePath.slice(0, lastSlashIndex);
19+
1820
// Create a variable to store the ext part of the variable
21+
const lastDotIndex = filePath.lastIndexOf(".");
22+
const ext = filePath.slice(lastDotIndex);
23+
24+
console.log(`The dir part of ${filePath} is ${dir}`);
25+
console.log(`The ext part of ${filePath} is ${ext}`);
1926

20-
const dir = ;
21-
const ext = ;
2227

23-
// https://www.google.com/search?q=slice+mdn
28+
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)