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 99
1010// (All spaces in the "" line should be ignored. They are purely for formatting.)
1111
12+
1213/* ================ lastIndexOf() ===================
13- -we use this to obtain the last position of / where is located the File.txt
14- -const base = filePath.slice(lastSlashIndex + 1); with + 1 we start to subtract after /
15- Index: 0 1 2 ... 37 38 39 40 41 42
16- filePath: / U s ... / f i l e .txt
17- -
14+
15+ -we use this to obtain the last position of / where is located the File.txt
16+ -const base = filePath.slice(lastSlashIndex + 1); with + 1 we start to subtract after /
17+ Index: 0 1 2 ... 37 38 39 40 41 42
18+ filePath: / U s ... / f i l e .txt
19+ -
1820*/
1921
2022const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt" ;
@@ -24,6 +26,7 @@ const base = filePath.slice(lastSlashIndex + 1);
2426console . log ( base ) ; // file.txt
2527// console.log(`The base part of ${filePath} is ${base}`);
2628
29+
2730// Create a variable to store the dir part of the filePath variable
2831const lastDotIndex = filePath . lastIndexOf ( "." ) ;
2932console . log ( lastDotIndex ) ; // index position 49
You can’t perform that action at this time.
0 commit comments