File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1212const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt" ;
1313const lastSlashIndex = filePath . lastIndexOf ( "/" ) ;
1414const base = filePath . slice ( lastSlashIndex + 1 ) ;
15- console . log ( `The base part of ${ filePath } is ${ base } ` ) ;
1615
1716// Create a variable to store the dir part of the filePath variable
1817// Create a variable to store the ext part of the variable
18+
19+ const lastDot = filePath . lastIndexOf ( "." ) ;
20+ console . log ( `The indexDot is ${ lastDot } ` ) ;
21+
22+ const ext = filePath . slice ( lastDot ) ;
23+
24+ const fileName = filePath . slice ( lastSlashIndex + 1 , lastDot ) ;
25+ const dir = filePath . slice ( 1 , lastSlashIndex + 1 ) ;
26+
27+
28+
29+ console . log ( `The dir is 👉 ${ dir } ` ) ;
30+ console . log ( `The nameFile is 👉 ${ fileName } ` ) ;
31+ console . log ( `The extension is 👉 ${ ext } ` ) ;
32+
33+
34+
You can’t perform that action at this time.
0 commit comments