Skip to content

Commit e3c2d1d

Browse files
committed
completed task 1 key exercises
1 parent 8f3d6cf commit e3c2d1d

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let count = 0;
22

3-
count = count + 1;
3+
count = count + 1; //line 3 is calculating the result of adding the current count value to 1 and assigning that to count.
44

55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ 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 = ``;
8+
let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`;
99

10-
// https://www.google.com/search?q=get+first+character+of+string+mdn
10+
console.log(initials); //testing my string
1111

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

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ 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 = ;
21-
const ext = ;
20+
const dir = filePath.slice(0, lastSlashIndex);
21+
const ext = base.slice(base.lastIndexOf(".") + 1);
2222

23-
// https://www.google.com/search?q=slice+mdn
23+
console.log(`The dir part of ${filePath} is ${dir}`);
24+
console.log(`The ext part of ${filePath} is ${ext}`);
25+
26+
// https://www.google.com/search?q=slice+mdn

Sprint-1/1-key-exercises/4-random.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

6+
//math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive). which we multiply by 100.
7+
//we round the above number to the largest interger less than or equal to the given outcome.
8+
//we add the value of minimum to the result.
9+
//num gives us a random number between 1 and 100.
10+
11+
console.log(num);
12+
613
// In this exercise, you will need to work out what num represents?
714
// Try breaking down the expression and using documentation to explain what it means
815
// It will help to think about the order in which expressions are evaluated

0 commit comments

Comments
 (0)