Skip to content

Commit 592a934

Browse files
committed
completed 3-paths
1 parent 465b99f commit 592a934

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ console.log(`The base part of ${filePath} is ${base}`);
1616

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
19+
const filePathArray = filePath.split("/");
20+
console.log("filePathArray", filePathArray);
21+
const lastDotIndex = filePath.lastIndexOf(".");
1922

20-
const dir = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file";
21-
const ext = ".txt";
22-
23+
const dir = filePathArray.slice(0,7).join("/");
24+
const ext = filePath.slice(lastDotIndex);
25+
console.log('dir', dir)
26+
console.log('ext', ext)
2327
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)