Skip to content

Commit ab072e7

Browse files
committed
Homework for Module 2 Stage 1
1 parent 3372770 commit ab072e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+143
-22
lines changed

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

Sprint-1/2-mandatory-errors/0.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

Sprint-1/2-mandatory-errors/1.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

Sprint-1/2-mandatory-errors/2.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

Sprint-1/2-mandatory-errors/4.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let count = 0;
2+
3+
count = count + 1;
4+
5+
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
6+
// 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.
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ 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 letter1 = firstName.charAt(0);
9+
let letter2 = middleName.charAt(0);
10+
let letter3 = lastName.charAt(0);
11+
12+
let initials = letter1 + letter2 + letter3;
13+
console.log(initials);
14+
15+
916

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

19+
Lines changed: 5 additions & 2 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+
console.log(`The dir part of ${filePath} is ${dir}`);
22+
23+
const ext = filePath.slice(lastSlashIndex + 1).split('.').pop();
24+
console.log(`The ext part of ${filePath} is ${ext}`);
2225

2326
// https://www.google.com/search?q=slice+mdn
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ 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+
//We start with 2 constant (unchangeable) values
13+
//We use them to generate a random number between 1 and 100 with Math.random()
14+
//The random number will always be an integer because Math.floor() is used to round
15+
//down the result.
16+
//At the end the value "minimum" is added to guarantee that the generated "num" is at least 1
17+
//"num" is a random number generator with results between 1 and 100.

Sprint1/2-mandatory-errors/0.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//This is just an instruction for the first activity - but it is just for human consumption
2+
//We don't want the computer to run these 2 lines - how can we solve this problem?
3+
4+
5+
//Starting a line with two forward slashes creates a comment.
6+
//This makes the computer ignore the rest of that line; it will not attempt to execute it.
7+
//It is advisable to use this feature lots because explaining the intention of the code
8+
//is helpful when cooperating with other people (and for your future self)

0 commit comments

Comments
 (0)