Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
1d8957c
Add hello_world.js file
moses77-boop Sep 14, 2026
cb5fd1c
Add hello_world.js file with initial console log
moses77-boop Sep 14, 2026
3dcb7b7
Add fact.js file
moses77-boop Sep 14, 2026
14998ae
Add fun fact about sprints to fact.js
moses77-boop Sep 14, 2026
4b9c01a
Rename file fact.js to facts.js
moses77-boop Sep 14, 2026
386a826
Add greeting.js file
moses77-boop Sep 14, 2026
ed354a3
Add greeting message to greeting.js
moses77-boop Sep 14, 2026
02c297f
Add console log for greeting message in greeting.js
moses77-boop Sep 14, 2026
d3c778f
Update greeting message to include name in greeting.js
moses77-boop Sep 14, 2026
0411379
Change greeting variable from const to let and update its value to "G…
moses77-boop Sep 14, 2026
c6ad8eb
Add boolean.js file
moses77-boop Sep 14, 2026
d2880fb
Add boolean.js with initial console log comparisons
moses77-boop Sep 14, 2026
2bddb02
Add additional comparison console logs in boolean.js
moses77-boop Sep 14, 2026
3f06814
Add passwordChecker.js file
moses77-boop Sep 15, 2026
1b3d99b
Add password validation logic in passwordChecker.js
moses77-boop Sep 15, 2026
56326fb
Add else statement to password validation logic
moses77-boop Sep 15, 2026
cae8927
Update userInput for password validation test
moses77-boop Sep 15, 2026
ad792cd
Add adminPassword variable in passwordChecker.js
moses77-boop Sep 15, 2026
31d8426
Add else if condition to password validation logic in passwordChecker.js
moses77-boop Sep 15, 2026
0f097a3
Add exercise.js file
moses77-boop Sep 15, 2026
1d56388
Remove unused exercise.js file
moses77-boop Sep 15, 2026
220a714
Add response variable declaration in passwordChecker.js
moses77-boop Sep 15, 2026
762e97f
Update else condition to assign response message for incorrect passwo…
moses77-boop Sep 15, 2026
39b87c3
Log response message for incorrect password in passwordChecker.js
moses77-boop Sep 15, 2026
3a1178c
Change response declaration from const to let in passwordChecker.js
moses77-boop Sep 16, 2026
c984e1a
Add console log for count variable in 1-count.js
moses77-boop Sep 16, 2026
ac61856
Add detailed comments explaining count variable increment in 1-count.js
moses77-boop Sep 16, 2026
d233466
Implement initials extraction from first, middle, and last names in 2…
moses77-boop Sep 16, 2026
ccf1a79
Add console log to display initials in 2-initials.js
moses77-boop Sep 16, 2026
6dbe2c4
Fix comment formatting for clarity in 1-count.js
moses77-boop Sep 16, 2026
15f4a87
Add solution comment for clarity in 2-initials.js
moses77-boop Sep 16, 2026
4eede60
Implement dir extraction from filePath and log the result in 3-paths.js
moses77-boop Sep 16, 2026
70f8230
Add variable assignment and Implement ext extraction logic in 3-paths.js
moses77-boop Sep 16, 2026
df08e0a
Add console log to display file extension in 3-paths.js
moses77-boop Sep 16, 2026
298f6d8
Add solution comment for clarity in 4-random.js
moses77-boop Sep 16, 2026
f291495
Add clarification comment for "num" in 4-random.js
moses77-boop Sep 16, 2026
e1edb49
Add breakdown comment in 4-random.js
moses77-boop Sep 16, 2026
cf88162
Add detailed breakdown comment for Math.random in 4-random.js
moses77-boop Sep 16, 2026
de4738f
Add additional breakdown comments in 4-random.js
moses77-boop Sep 16, 2026
d93a91d
Add additional breakdown comments in 4-random.js
moses77-boop Sep 16, 2026
20ea364
Add breakdown comments for Math.floor in 4-random.js
moses77-boop Sep 16, 2026
e10fbf9
Add explanation for shifting range in random number generation
moses77-boop Sep 16, 2026
57981df
Add console log for generated random number in 4-random.js
moses77-boop Sep 16, 2026
6ac46a6
Refactor comments in 4-random.js for readability
moses77-boop Sep 16, 2026
0175ffc
Wrap instructional lines in multi-line comment and add solution expla…
moses77-boop Sep 16, 2026
05aa2b7
Change age variable from const to let for reassignment
moses77-boop Sep 16, 2026
15a4e9a
Add console log for updated age variable
moses77-boop Sep 16, 2026
557caf0
Add reference error comment for cityOfBirth initialization issue
moses77-boop Sep 16, 2026
08f2261
Add explanation comment for cityOfBirth reference error
moses77-boop Sep 16, 2026
1d0d876
Fix ReferenceError by declaring cityOfBirth before initializing conso…
moses77-boop Sep 16, 2026
c4049e2
Add prediction and explanation comments for cardNumber slicing issue
moses77-boop Sep 16, 2026
466f652
Add console log for last4Digits
moses77-boop Sep 16, 2026
4c83857
Add error message and explanation for cardNumber slicing issue
moses77-boop Sep 16, 2026
3fe8bc3
Fix last4Digits assignment by converting cardNumber to string for sli…
moses77-boop Sep 16, 2026
d65f2eb
Add console log for 12-hour and 24-hour clock times
moses77-boop Sep 16, 2026
0c7b749
Add comments explaining SyntaxError due to invalid identifier names
moses77-boop Sep 16, 2026
5486566
Fix variable names by renaming identifiers starting with digits
moses77-boop Sep 16, 2026
b23cf15
Add solution comments detailing function calls in 1-percentage-change.js
moses77-boop Sep 16, 2026
84c9f96
Add error explanation in 1-percentage-change.js
moses77-boop Sep 16, 2026
f4a107a
Add error resolution comment for SyntaxError in 1-percentage-change.js
moses77-boop Sep 16, 2026
37cab85
Fix syntax error by adding missing comma in replaceAll function call …
moses77-boop Sep 16, 2026
9e31beb
Add comments for variable reassignment statements in 1-percentage-cha…
moses77-boop Sep 16, 2026
0a35180
Add comments for variable declarations in 1-percentage-change.js
moses77-boop Sep 16, 2026
722ed1c
Add detailed explanation for Number conversion in 1-percentage-change.js
moses77-boop Sep 16, 2026
41ef602
Add solution comments for variable declarations in 2-time-format.js
moses77-boop Sep 17, 2026
b9beadc
Add explanation for function call in 2-time-format.js
moses77-boop Sep 17, 2026
b96468b
Add detailed explanation for remainder operator in 2-time-format.js
moses77-boop Sep 17, 2026
d6a7f93
Add explanation for totalMinutes calculation in 2-time-format.js
moses77-boop Sep 17, 2026
179fcb4
Add explanation for totalMinutes calculation, result meaning and sugg…
moses77-boop Sep 17, 2026
2926cd8
Refactor convert function to encapsulate logic and test with various …
moses77-boop Sep 17, 2026
01db8a2
Refactor convert function to return formatted time instead of logging it
moses77-boop Sep 17, 2026
6f6bcad
Add notes on limitations of movieLength handling in convert function
moses77-boop Sep 17, 2026
ea7dbc1
Add detailed explanation for penceStringWithoutTrailingP processing i…
moses77-boop Sep 18, 2026
893336e
Add detailed explanation for paddedPenceNumberString processing in 3-…
moses77-boop Sep 18, 2026
6468f29
Add detailed explanation for pounds extraction in 3-to-pounds.js
moses77-boop Sep 18, 2026
2baa16a
Add detailed explanation for pence calculation in 3-to-pounds.js
moses77-boop Sep 18, 2026
fdcbeb0
Clarify explanation for paddedPenceNumberString processing in 3-to-po…
moses77-boop Sep 18, 2026
105bbf8
Add explanation for pence calculation in 3-to-pounds.js
moses77-boop Sep 18, 2026
c524311
Add explanation for final output in 3-to-pounds.js
moses77-boop Sep 18, 2026
361a9e7
Clarify explanation for substring method in pounds extraction in 3-to…
moses77-boop Sep 18, 2026
4253d8f
Delete prep directory
moses77-boop Sep 18, 2026
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
6 changes: 6 additions & 0 deletions Sprint-2/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ 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
console.log(count);

//Line 3 reads the current value of <count>, which is <0>, and computes <count + 1>, which turns out to be 1.
//It also assigns the new value <1> to the variable <count>, overwriting the initial value <0>.
//The assignment operator "=" means, take the value on the right, and store it in the variable on the left.
//Console.log(count) prints out the result of Line 3.
5 changes: 3 additions & 2 deletions Sprint-2/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const 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.

const initials = ``;
//Solution
const initials = `${firstName[0]} ${middleName[0]} ${lastName[0]} `;

// https://www.google.com/search?q=get+first+character+of+string+mdn
console.log(initials);
9 changes: 7 additions & 2 deletions Sprint-2/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ 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 = ;
//Solution
const dir = filePath.slice(0, lastSlashIndex);
console.log(`The dir part of ${filePath} is ${dir}`);

const lastDotIndex = base.lastIndexOf(".");
const ext = base.slice(lastDotIndex);
console.log(`The ext part of ${filePath} is ${ext}`);

// https://www.google.com/search?q=slice+mdn
24 changes: 20 additions & 4 deletions Sprint-2/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ const minimum = 1;
const maximum = 100;

const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
console.log(num);

// In this exercise, you will need to work out what num represents?
// 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

//Solution
//- "num" represents a random whole number between 1 and 100.

//Break down of expression
//-Math.random: This generates a random decimal number between 0 and 1. It can return 0, but never reaches 1. (Example: 0.876).

//-(maximum - minimum + 1):
// This expression can be simplified as (100 - 1 + 1), which equals 100. This tells the program how many possible whole numbers there are. There are 100 possibilities.
// The +1 is important as without it, we would only reach 99 possibilities, that is 0 - 99.

//-Math.random() * (maximum - minimum + 1):
// This function multiplies the random decimal by the range size. Since Math.random() represents numbers >=0 and <1, this expression produces value anywhere from 0 up to 100, excluding 100.
// Example to justify expression: 0.876 * 100 = 87.6

//-Math.floor: This static method rounds down to the nearest whole number, discarding the decimal. This turns the continuous range into whole numbers, from 0 - 99.
// That is 87.6 becomes 87.

// + minimum: This shifts the whole range up by adding 1. So instead of landing on 0 - 99, we have 1 - 100.
7 changes: 5 additions & 2 deletions Sprint-2/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?*/

//Solution
//This problem was solved by wrapping the statement in a multi-line comment tag. This way the lines are stopped from executing.
4 changes: 3 additions & 1 deletion Sprint-2/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// 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);
6 changes: 5 additions & 1 deletion Sprint-2/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Currently trying to print the string "I was born in Bolton" but it isn't working...
// what's the error ?

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);


//ReferenceError: Cannot access 'cityOfBirth' before initialization.
//console.log tries to use cityOfBirth inside the template literal, but cityOfBirth has not been declared yet at that point in the code.
14 changes: 13 additions & 1 deletion Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
const last4Digits = String(cardNumber).slice(-4);

// The last4Digits variable should store the last 4 digits of cardNumber
// However, the code isn't working
// Before running the code, make and explain a prediction about why the code won't work
// Then run the code and see what error it gives.
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
// Then try updating the expression last4Digits is assigned to, in order to get the correct value


//Solution
//Prediction - The code would not run because 'cardNumber' is declared as numbers instead of a string.
// The '.slice()' method belongs to strings and arrays, it could only work by treating it's subject as a sequence of characters.

console.log(last4Digits);

//Error message - TypeError: cardNumber.slice is not a function
//Reason for error
//The error thrown was considerably as predicted.
//'.slice()' is a method defined on 'String.prototype', and since 'cardNumber' was declared with a numeric literal, JavaScript treats it as the 'number' type.
9 changes: 7 additions & 2 deletions Sprint-2/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
const ClockTime12Hour = "8:53pm";
const ClockTime24hour = "20:53";

console.log(ClockTime12Hour, ClockTime24hour);

//There is a SyntaxError after running the code.
//This error occurred because the identifiers '12HourClockTime' and '24hourClockTime' both start with a digit.
32 changes: 31 additions & 1 deletion Sprint-2/3-mandatory-interpret/1-percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let carPrice = "10,000";
let priceAfterOneYear = "8,543";

carPrice = Number(carPrice.replaceAll(",", ""));
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));

const priceDifference = carPrice - priceAfterOneYear;
const percentageChange = (priceDifference / carPrice) * 100;
Expand All @@ -20,3 +20,33 @@ console.log(`The percentage change is ${percentageChange}`);
// d) Identify all the lines that are variable declarations

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?


//Solution
// a) There are 5 function calls on lines 4, 5, and 9.
// Line 4: carPrice.replaceAll(",","")
// Line 4: Number()
// Line 5: priceAfterOneYear.replaceAll("," "")
// Line 5: Number()
// Line 9: console.log()

// b) Line 5 seems to broken.
// Error message - SyntaxError: missing ) after argument list
// Reason for error: There is a missing comma between two arguments of replaceAll.
// To fix the error, we need to add the missing comma between the arguments of replaceAll.

// c) Lines 4 and 5 contain variable reassignment statements
// Line 4: carPrice = Number()
// Line 5: priceAfterOneYear = Number()

// d) Lines 1, 2, 7, and 8 contain variable declarations
// Line 1: let carPrice = "10,000";
// Line 2: let priceAfterOneYear = "8,543";
// Line 7: const priceDifference = carPrice - priceAfterOneYear;
// Line 8: const percentageChange = (priceDifference / carPrice) * 100;

// e) Number(carPrice.replaceAll(",","")) is two steps combined, whereby:
// carPrice.replaceAll(",","") takes the string "10,000" and deletes every comma, making it 10000
// and Number() converts the new string into an actual numeric value
// The purpose of the expression is to strip out the formatting comma first from the string
// so that JavaScript does not treat it as plain text, and then converts the result into real numbers for it to be used in math, similar to Line 7
45 changes: 42 additions & 3 deletions Sprint-2/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const movieLength = 8784; // length of movie in seconds
//const movieLength = 8784; // length of movie in seconds
function convert(movieLength){

const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;

const remainingMinutes = totalMinutes % 60;
const totalHours = (totalMinutes - remainingMinutes) / 60;

const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
console.log(result);
return `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
//const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
//console.log(result);
}

[65, -100, 90.5, "8784"].forEach(v => {
console.log(v, "->", convert(v));
});

// For the piece of code above, read the code and then answer the following questions

Expand All @@ -23,3 +30,35 @@ console.log(result);
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer



//Solution
// a) There are 6 declared variables in this program, all declared with 'const'
// - const movieLength
// - const remainingSeconds
// - const totalMinutes
// - const remainingMinutes
// - const totalHours
// - const result

// b) There is just 1 function call: console.log(result);

// c) In the expression 'movieLength % 60', '%' represents the remainder operator. It returns the value that of what is left over after dividing the left operand by the right operand as many whole times as possible.
// Since movieLength = 8784, it means: 8784 % 60, which returns a result of 146 remainder 24.
// Therefore, movieLength % 60 (8784 % 60) returns the leftover value '24'. In this context, the leftover represents the loose seconds that add up to a full minute.

// d) The expression assigned to totalMinutes simply means, we subtract the loose seconds, '24', from movieLength, '8784'. The result becomes a number easily divisible by 60
// That is: totalMinutes = (8784 - 24);
// which gives 8760, and then divides it 60;
// the result, 146, is the total number of complete minutes contained in the movie

// e) The variable 'result' is a template literal syntax which holds the movie's length formatted as a colon-separated time string: as in '2:26:24'.
// A better name for 'result' could have been 'movieLengthDisplay'

// f) This program did not work for all values of movieLength
// Some problems discovered
// - for movieLength 65 there was an issue with zero-padding, '65' becomes '0:1:5' instead of the conventional '00:01:05'. Returning single-digit minutes/seconds look wrong in a real time display
// - negative integer, '-100', produced '0:-1:-40', which is inaccurate for a duration
// - non-integer input, 90.5, was not handled as it gives '0:1:30.5'. This implies that a fractional second had slipped through untouched, since nothing was truncated.
// - string input "8784" works here because operators '%', '-', and '/' automatically converts strings to numbers, but that is fragile and relies on the type conversion rather than actual input validation
27 changes: 27 additions & 0 deletions Sprint-2/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,30 @@ console.log(`£${pounds}.${pence}`);

// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"

// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1);
// substring(0, length - 1): is a method that is invoked in the paragraph above to take every character in the string provided except the last one, leaving out the 'p'
// That is -> '399p' becomes '399'
// const penceStringWithoutTrailingP: used to store the value from 'penceString.substring(...)'

// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
// penceStringWithoutTrailingP is now '399'
// padStart(3, "0") is a method used above which guarantees that the numeric string is at least 3 characters long, and if it is shorter add '0' to the front until it is 3 characters long.
// padding to 3 ensures there is always at least 3 digits, that is, one pounds digit and two pence digits.
//

// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
// since paddedPenceNumberString is '399' and it's '.length' is 3
// this line is saying: '399.substring(0, 3 - 2)', which becomes '399.substring(0, 1)'
// 'substring' is a method used to grab characters from this string, starting from the left, from position '0' up to, but not including, position '1'
// 'const pounds' would be assigned the new value: '3'

// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
// since paddedPenceNumberString.length is '3'
// then 'paddedPenceNumberString.substring(3 - 2)' becomes 'paddedPenceNumberString.substring(1)': this means grab everything from position '1' of the string to the end.
// That is -> '399.substring(1)' becomes '99'
// '.padEnd(2, "0") is another method that ensures the string is at least 2 characters long and adding '0' to the end if it's too short.
// 'const pence' would be assigned the new value: '99'

// 6. console.log(`£${pounds}.${pence}`): This template string calls the result of two pieces, 'pounds' which is '3' and 'pence' which '99'
// Overall result: £3.99
Loading