Skip to content

Commit affd78a

Browse files
committed
update: fix ext extraction logic in 3-paths.js
1 parent d17fa1d commit affd78a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ const base = filePath.slice(lastSlashIndex + 1);
1515
console.log(`The base part of ${filePath} is ${base}`);
1616

1717
// Create a variable to store the dir part of the filePath variable
18-
// Create a variable to store the ext part of the variable
18+
1919

2020
const dir = filePath.slice(0, lastSlashIndex);// The code uses the lastIndexOf method to find the position of the last slash in;
2121
console.log(`The dir part of ${filePath} is ${dir}`);
2222
filePath.slice(0, lastSlashIndex);
23-
const ext = filePath;
23+
2424
filePath
2525
.slice(lastSlashIndex + 1)
2626
.split(".")
2727
.pop();
28-
// The code above uses the lastIndexOf method to find the position of the last slash in the filePath string.
29-
// The slice method is then used to extract the base part of the filePath string, which is the part after the last slash.
28+
// Create a variable to store the ext part of the variable
29+
30+
const ext=base.slice(base.lastIndexOf(".") + 1);
31+
console.log(`The ext part of ${filePath} is ${ext}`);

0 commit comments

Comments
 (0)