File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1010// (All spaces in the "" line should be ignored. They are purely for formatting.)
1111
1212const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt" ;
13+
1314const lastSlashIndex = filePath . lastIndexOf ( "/" ) ;
15+
1416const base = filePath . slice ( lastSlashIndex + 1 ) ;
17+
1518console . 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
You can’t perform that action at this time.
0 commit comments