Skip to content

Commit 33458e1

Browse files
correcting exercise 3-paths.js
1 parent b1e0fc1 commit 33458e1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ 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(1,lastSlashIndex);
20+
const dir = filePath.slice(0,lastSlashIndex);
21+
/*correction : slice(0,lastSlashIndex); is the correct method to extract the dir path
22+
filePath.slice(start, end) => 0 represents the character 0 of the filePath String put 1 will skip the first charchter.
23+
*/
24+
25+
2126
const ext = filePath.slice(filePath.lastIndexOf(".")+1);
2227

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

2530
console.log(`The dir part of the filePath ${filePath}variable is ${dir}`);
2631

27-
console.log(`The ext part of a variable file.txt is ${ext}`);
32+
console.log(`The ext part of a variable file.txt is ${ext}`);
33+

0 commit comments

Comments
 (0)