Skip to content

Commit b82600e

Browse files
committed
created 2 variables in 3-paths.js , one is to store the fir part of the filepath variable, the other is store the ext part of the variable
1 parent 38f900a commit b82600e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
// (All spaces in the "" line should be ignored. They are purely for formatting.)
1111

1212
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
13+
1314
const lastSlashIndex = filePath.lastIndexOf("/");
15+
1416
const base = filePath.slice(lastSlashIndex + 1);
17+
1518
console.log(`The base part of ${filePath} is ${base}`);
1619

1720
// Create a variable to store the dir part of the filePath variable
1821
// Create a variable to store the ext part of the variable
1922

20-
const dir = ;
21-
const ext = ;
23+
const dir = filePath.slice(0, lastSlashIndex + 1);
24+
const ext = filePath.slice(filePath.lastIndexOf("."));
2225

26+
// to test >>
27+
//console.log(`The dir part of filePath is (( ${dir} )) AND the ext part of it is (( ${ext} ))`);
2328
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)