Skip to content

Commit 5707079

Browse files
committed
Complete 1-key-exercises
1 parent 80889d4 commit 5707079

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ count = count + 1;
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
7+
8+
// Line 3 is reassigning the 'count' variable to it's initial value plus one

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 = `${
9+
firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0)
10+
}`;
911

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ 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(1, lastSlashIndex);
21+
const ext = base.split(".")[1];
2222

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77
// Try breaking down the expression and using documentation to explain what it means
88
// It will help to think about the order in which expressions are evaluated
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10+
11+
// The num variable will evaluate to a random number between the minimum and maximum values
12+
13+
// Math.random()
14+
// Random decimal number (0 - 1)
15+
16+
// (maximum - minimum + 1)
17+
// The size of the range
18+
19+
// Math.random() * (maximum - minimum + 1)
20+
// Random decimal (0 - 100)
21+
22+
// Math.floor(...)
23+
// Rounds the result down to a whole number (0 - 99)
24+
25+
// Adding minimum shifts the range up, so the final result is between the minimum and maximum (1 - 100 inclusive)

0 commit comments

Comments
 (0)