File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,13 @@ 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 = ;
22-
23- // https://www.google.com/search?q=slice+mdn
20+ const dir = filePath . slice ( 0 , lastSlashIndex ) ; // The code uses the lastIndexOf method to find the position of the last slash in;
21+ console . log ( `The dir part of ${ filePath } is ${ dir } ` ) ;
22+ filePath . slice ( 0 , lastSlashIndex ) ;
23+ const ext = filePath ;
24+ filePath
25+ . slice ( lastSlashIndex + 1 )
26+ . split ( "." )
27+ . pop ( ) ;
28+ // The code above uses the lastIndexOf method to find the position of the last slash in the filePath string.
29+ // The slice method is then used to extract the base part of the filePath string, which is the part after the last slash.
You can’t perform that action at this time.
0 commit comments