Skip to content

Commit f81891c

Browse files
committed
completed the 1-key-exercises of sprint-1
1 parent 3372770 commit f81891c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
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 updating the value of the count variable. The = operator is an assignment operator, which assigns the value on the right (count + 1) to the variable on the left (count). In this case, it takes the current value of count (which is 0), adds 1 to it, and then assigns the result (1) back to count. So after this line executes, count will have a new value of 1.

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

Lines changed: 2 additions & 1 deletion
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];
9+
console.log(initials);
910

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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ 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+
console.log(`The dir part of ${filePath} is ${dir}`);
22+
const ext = filePath.slice(filePath.lastIndexOf("."));
23+
console.log(`The ext part of ${filePath} is ${ext}`);
2224

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

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ 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+
12+
// minimum is 1, maximum is 100
13+
14+
// Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive). So it can be any value from 0 up to but not including 1.
15+
// (maximum - minimum + 1) calculates the range of possible values, which is 100 - 1 + 1 = 100. This means we want to generate a random number between 0 and 99 (inclusive) before adding the minimum value.
16+
// Math.random() * (maximum - minimum + 1) gives us a random decimal number between 0 (inclusive) and 100 (exclusive). This means it can be any value from 0 up to but not including 100.
17+
// Math.floor() takes the random decimal number and rounds it down to the nearest whole number. This means we will get an integer value between 0 and 99 (inclusive).
18+
// Finally, we add the minimum value (1) to the result, which shifts the range from 0-99 to 1-100. So num will be a random integer between 1 and 100 (inclusive).

0 commit comments

Comments
 (0)