Skip to content

Commit 54de241

Browse files
Fixing the first 3 work from 1-key-excercise
1 parent 8d780b8 commit 54de241

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Sprint-1/1-key-exercises/1-count.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
let count = 0;
22

33
count = count + 1;
4-
/* in line three, the variable count is combining the variable count original value of 0 with new value of 1 with the used of plus operator.
5-
The equal operator is this case helping to re-assign the new value back to the count variable
4+
/* in line three, the variable count is reassign new value by increment it current value by 1.
65
*/
76
console.log(count);
87

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let lastName = "Johnson";
55
// Declare a variable called initials that stores the first character of each string.
66
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
77

8-
let initials = firstName.slice(0,1)+middleName.slice(0,1)+lastName.slice(0,1);
8+
let initials = firstName.charAt(0)+middleName.charAt(0)+lastName.charAt(0);
99
console.log(initials);
1010

1111
// https://www.google.com/search?q=get+first+character+of+string+mdn

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,24 @@ 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+
/*
1920
const slashIndex = filePath.indexOf("/");
2021
const dir =filePath.slice(slashIndex + 0, 45) ;
2122
const ext =filePath.slice(slashIndex + 49, 53);
2223
console.log(`The dir part of ${filePath} is ${dir}`);
2324
console.log(`The ext part of ${filePath} is ${ext}`);
25+
*/
26+
27+
function pathFinder(path){
28+
const lastSlash = path.lastIndexOf("/");
29+
const dir = path.slice(0, lastSlash);
30+
const base = path.slice(lastSlash + 1);
31+
const dot = base.lastIndexOf(".");
32+
const ext = dot !== -1 ? base.slice(dot) : "";
33+
34+
return { dir, base, ext };
35+
}
36+
37+
console.log(pathFinder(filePath));
38+
2439
// https://www.google.com/search?q=slice+mdn

0 commit comments

Comments
 (0)