Skip to content

Commit a7ffaa8

Browse files
committed
update: Implement dir and ext variable assignments in 3-paths.js
1 parent b57e0f3 commit a7ffaa8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Sprint-1/1-key-exercises/3-paths.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ 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 = ;
20+
const dir = filePath;
21+
filePath.slice(0, lastSlashIndex);
22+
const ext = filePath;
23+
filePath
24+
.slice(lastSlashIndex + 1)
25+
.split(".")
26+
.pop();
27+
// The code above uses the lastIndexOf method to find the position of the last slash in the filePath string.
28+
// The slice method is then used to extract the base part of the filePath string, which is the part after the last slash.
2229

23-
// https://www.google.com/search?q=slice+mdn
30+
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)