You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1cf24f7
Browse filesBrowse the repository at this point in the historyBrowse files
// a variable is created and identified to find the last occurance of the "/" character in the filePath variable, which is used to separate directories and files in a file system
37
-
//const base = filePath.slice(lastSlashIndex + 1);
38
-
// a variable is created and identified to extract the base part of the filePath variable, which is the name of the file and its extension, by using the slice method
39
-
//console.log(`The base part of ${filePath} is ${base}`);
40
-
// console.log is used to print the base part of the filePath variable to the console, which is the name of the file and its extension
13
+
constlastSlashIndex=filePath.lastIndexOf("/");
14
+
constbase=filePath.slice(lastSlashIndex+1);
15
+
console.log(`The base part of ${filePath} is ${base}`);
41
16
42
17
// Create a variable to store the dir part of the filePath variable
43
18
// Create a variable to store the ext part of the variable
44
19
45
-
constlastSlashIndex=filePath.lastIndexOf("/");
46
20
// here we have the variable lastslashIndex already created and identified its position
47
-
// stores the position or (index) of "/" in filePath, so this "/" is used as a symbol that storers the number index or a place that seprate dir from base
21
+
// stores the position or (index) of "/" in filePath, so this "/" is used as a symbol that storers the number index or a place that seprate dir from base
48
22
constdir=filePath.slice(0,lastSlashIndex);
49
23
console.log(dir);
50
24
// we show our result in the console
51
-
constlastDotIndex=filePath.lastIndexOf('.');
25
+
constlastDotIndex=filePath.lastIndexOf(".");
52
26
// we create a variable and assign its value using the indexOf to be from the dot location
53
27
constext=filePath.slice(lastDotIndex);
54
28
// we create a variable where we assign its value using the slice method to be from the dot only
55
29
56
-
console.log(ext)
30
+
// https://www.google.com/search?q=slice+mdn
31
+
32
+
console.log(ext);
57
33
// we print our result in the console
58
34
//slice(startIndex, endIndex)
59
35
// means, start here and stop here. we are doing this to seprate the dir from base so we need to tell it where to start and where to end, hence that is why we use slice method,
60
-
// my comments needs correcting to look profissional -_-
36
+
// my comments needs correcting to look profissional -_-
0 commit comments