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
1 change: 1 addition & 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,4 @@ 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
// This line (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).
3 changes: 1 addition & 2 deletions Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ 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] + middleName[0] + lastName[0];

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

4 changes: 2 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,7 @@ 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 ext = base.slice(base.lastIndexOf("."));

// https://www.google.com/search?q=slice+mdn
13 changes: 13 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,16 @@ 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

// Math.random returns a random number between 0 (inclusive) and 1 (exclusive).
// const minimum = 1; const maximum = 100; +1 so, 100 - 1 + 1 = 100
// Math.random() * 100 means the decimal number will be multiplied by 100, so the range of possible values is from 0 to 99.9999...
// Math.floor rounds the number down to the nearest whole number, so the possible values are from 0 to 99.
// Eg. 12.9 becomes 12, 0.3 becomes 0, 99.9 becomes 99.
// Brackets(), Multiply*, Function(Math.floor), Addition+
// 1) Pick a random number between 0 and 1, eg. 0.5
// 2) Multiply that number by 100, eg. 0.5 * 100 = 50
// 3) Round that number down to the nearest whole number, eg. Math.floor(50) = 50
// 4) Add 1 to that number, eg. 50 + 1 = 51

// num represents a random whole number between 1 and 100.
5 changes: 3 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
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?
// The forward slash is used to indicate a comment in JavaScript, so the computer will ignore these lines when running the program.
6 changes: 5 additions & 1 deletion Sprint-1/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// trying to create an age variable and then reassign the value by 1

const age = 33;
let age = 33;
age = age + 1;
console.log(age);

// The code above will output 34, because we are reassigning the value of age to be the current value of age plus 1. So, 33 + 1 = 34.