File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,11 +17,17 @@ 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 = filePath . slice ( 1 , lastSlashIndex ) ;
20+ const dir = filePath . slice ( 0 , lastSlashIndex ) ;
21+ /*correction : slice(0,lastSlashIndex); is the correct method to extract the dir path
22+ filePath.slice(start, end) => 0 represents the character 0 of the filePath String put 1 will skip the first charchter.
23+ */
24+
25+
2126 const ext = filePath . slice ( filePath . lastIndexOf ( "." ) + 1 ) ;
2227
2328// https://www.google.com/search?q=slice+mdn
2429
2530console . log ( `The dir part of the filePath ${ filePath } variable is ${ dir } ` ) ;
2631
27- console . log ( `The ext part of a variable file.txt is ${ ext } ` ) ;
32+ console . log ( `The ext part of a variable file.txt is ${ ext } ` ) ;
33+
You can’t perform that action at this time.
0 commit comments