File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 11// The diagram below shows the different names for parts of a file path on a Unix operating system
22
33// ????????????????????????????????????
4- // ? dir ? base ?
5- // ???????? ??????????????
6- // ? root ? ? name ? ext ?
4+ // ┌─────────────────────┬────────────┐
5+ // │ dir │ base │
6+ // ├──────┬ ├──────┬─────┤
7+ // │ root │ │ name │ ext │
78// " / home/user/dir / file .txt "
8- // ????????????????????????????????????
9+ // └──────┴──────────────┴──────┴─────┘
910
1011// (All spaces in the "" line should be ignored. They are purely for formatting.)
1112
@@ -17,7 +18,9 @@ console.log(`The base part of ${filePath} is ${base}`);
1718// Create a variable to store the dir part of the filePath variable
1819// Create a variable to store the ext part of the variable
1920
20- const dir = filePath . slice ( filePath . indexOf ( "/" ) + 1 , lastSlashIndex ) ;
21+ const dir = filePath . slice ( filePath . indexOf ( "/" ) , lastSlashIndex ) ;
2122const ext = base . slice ( base . lastIndexOf ( "." ) ) ;
2223
24+ console . log ( dir ) ;
25+
2326// https://www.google.com/search?q=slice+mdn
You can’t perform that action at this time.
0 commit comments