File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,11 +13,16 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
1313const lastSlashIndex = filePath . lastIndexOf ( "/" ) ;
1414const base = filePath . slice ( lastSlashIndex + 1 ) ;
1515console . log ( `The base part of ${ filePath } is ${ base } ` ) ;
16+ // console.log('The dir path of ${dir} is ${filePath}.${lastSlashIndex}');
17+
1618
1719// Create a variable to store the dir part of the filePath variable
1820// Create a variable to store the ext part of the variable
1921
20- const dir = ;
21- const ext = ;
22+ const dir = filePath . slice ( 0 , lastSlashIndex ) ;
23+ const ext = base . slice ( base . lastIndexOf ( "." ) ) ;
24+
25+ console . log ( `The dir part of ${ filePath } is ${ dir } ` ) ;
26+ console . log ( `The ext part of ${ base } is ${ ext } ` ) ;
2227
2328// https://www.google.com/search?q=slice+mdn
You can’t perform that action at this time.
0 commit comments