Skip to content

Commit 987c2ce

Browse files
committed
1-key-exercises are done.
1 parent b31a586 commit 987c2ce

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ let count = 0;
22

33
count = count + 1;
44

5+
console.log(count);
6+
57
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
68
// Describe what line 3 is doing, in particular focus on what = is doing
9+
// Line 3 adds 1 to the current value of count. The = sign means we save the new value back into count. Since count started at 0, count + 1 makes it 1

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ let firstName = "Creola";
22
let middleName = "Katherine";
33
let lastName = "Johnson";
44

5+
let initials = firstName[0] + middleName[0] + lastName[0];
6+
console.log(initials);
7+
58
// Declare a variable called initials that stores the first character of each string.
69
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
710

8-
let initials = ``;
9-
1011
// https://www.google.com/search?q=get+first+character+of+string+mdn
11-

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 = filePath.slice(filePath.lastIndexOf("."));
2222

23-
// https://www.google.com/search?q=slice+mdn
23+
console.log(dir);
24+
console.log(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
@@ -4,6 +4,13 @@ const maximum = 100;
44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
// In this exercise, you will need to work out what num represents?
7+
// num creates a random whole number between 1-100 (inclusive).
78
// Try breaking down the expression and using documentation to explain what it means
9+
//maximum-minimum+1 gives us the number of possible values (100-1+1 = 100)
10+
//Math.random() gives us a random decimal number between 0 (inclusive) and 1 (exclusive)
11+
//Multiplying Math.random() by 100 gives us a random decimal number between 0 and 100 (exclusive)
12+
//Math.floor() rounds down the random decimal number to the nearest whole number.
13+
//Adding minimum to the result gives us a random whole number between minimum and maximum (inclusive)
814
// It will help to think about the order in which expressions are evaluated
915
// Try logging the value of num and running the program several times to build an idea of what the program is doing
16+
console.log(num);

0 commit comments

Comments
 (0)