File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,19 @@ console.log(`The base part of ${filePath} is ${base}`);
1717// Create a variable to store the dir part of the filePath variable
1818// Create a variable to store the ext part of the variable
1919
20- const dir = ;
21- const ext = ;
20+ //Answer:
21+ //**where the file lives^^
22+ // It gives me everything from Index 0 to
23+ // the last slash just before the filename.
24+ const dir = filePath . slice ( 0 , lastSlashIndex ) ;
25+ console . log ( dir ) ;
26+
27+ //Answer:
28+ //**what type of file**
29+ //Uses the the lastIndexOf method to look for the dot.
30+ //the dot is now index 0 so we start from index 1 onwards
31+ // to get the file type.
32+ const ext = filePath . slice ( filePath . lastIndexOf ( "." ) + 1 ) ;
33+ console . log ( ext ) ;
2234
2335// https://www.google.com/search?q=slice+mdn
You can’t perform that action at this time.
0 commit comments