Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ count = count + 1;

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing
// line 3 is updating the value of count by adding 1 to its current value and then assigning that new value back to count.
// the assignemt operator (=) is used to assign the result of the expression (count + 1) back to the variable count, effectively updating its value.
3 changes: 2 additions & 1 deletion Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let lastName = "Johnson";
// Declare a variable called initials that stores the first character of each string.
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.

let initials = ``;
let initials = `${firstName[0].toUpperCase()}${middleName[0].toUpperCase()}${lastName[0].toUpperCase()}`;
console.log(initials);

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

5 changes: 3 additions & 2 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ console.log(`The base part of ${filePath} is ${base}`);
// Create a variable to store the dir part of the filePath variable
// Create a variable to store the ext part of the variable

const dir = ;
const ext = ;
const dir = filePath.slice(0, lastSlashIndex);
const lastDotIndex = filePath.lastIndexOf(".");
const ext = filePath.slice(lastDotIndex + 1);

// https://www.google.com/search?q=slice+mdn
9 changes: 9 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing

// breaking down the expressions:
// num is assigned the value of Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
// Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive)
// (maximum - minimum + 1) calculates the range of possible values, which is 100 - 1 + 1 = 100
// Math.random() * (maximum - minimum + 1) scales the random decimal to the range of possible values, resulting in a number between 0 and 100 (exclusive)
// Math.floor() rounds down the scaled random number to the nearest whole number, giving us an integer between 0 and 99
// Finally, adding minimum (which is 1) shifts the range from 0-99 to 1-100, resulting in num being a random integer between 1 and 100 (inclusive)
console.log(num);
7 changes: 5 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
This is just an instruction for the first activity - but it is just for human consumption
We don't want the computer to run these 2 lines - how can we solve this problem?
//This is just an instruction for the first activity - but it is just for human consumption
//We don't want the computer to run these 2 lines - how can we solve this problem?

// we can use comments to prevent the computer from running these lines of code
// this is a comment and will not be executed by the computer