Skip to content

Commit 0dfa642

Browse files
committed
trailing / removed and recomended approach taken
1 parent 6f289e8 commit 0dfa642

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ 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 = filePath.slice(0, lastSlashIndex + 1);
21-
const ext = filePath.slice(-3); //the extention of the file is always the last three characters in the path
22-
//or
23-
//const lastPointIndex = filePath.lastIndexOf(".");
24-
//const ext = filePath.slice(lastPointIndex+1);
20+
const dir = filePath.slice(0, lastSlashIndex);
21+
22+
const lastPointIndex = filePath.lastIndexOf(".");
23+
const ext = filePath.slice(lastPointIndex + 1);
2524

2625
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)