Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2300ec7
Add comments for count variable and assignment
anitahy73 Sep 20, 2026
77546b4
Generate initials from name variables
anitahy73 Sep 20, 2026
1e39939
Fix comments in 1-count.js for clarity
anitahy73 Sep 20, 2026
d6958a1
Extract directory and extension from filePath
anitahy73 Sep 20, 2026
6c5f201
Enhance comments for random number explanation
anitahy73 Sep 20, 2026
4b1bd0d
Comment out instructions in 0.js
anitahy73 Sep 20, 2026
424ec1c
Change age variable to let and reassign value
anitahy73 Sep 20, 2026
18a1da4
Correct cityOfBirth declaration for logging
anitahy73 Sep 20, 2026
418784e
Fix last4Digits assignment to handle cardNumber correctly
anitahy73 Sep 20, 2026
7753eb9
Fix variable naming for clock time constants
anitahy73 Sep 20, 2026
b3a99c0
Fix missing comma in replaceAll function call
anitahy73 Sep 20, 2026
ab458e3
Add answers to code interpretation questions
anitahy73 Sep 20, 2026
78097f1
Enhance code readability with detailed comments
anitahy73 Sep 20, 2026
e953ec6
Update explanations for alert and prompt functions
anitahy73 Sep 20, 2026
87532a7
Fix type conversion for last 4 digits extraction
anitahy73 Sep 21, 2026
87d18e1
Fix age reassignment to increment by 1
anitahy73 Sep 21, 2026
77da0b4
Update comment for clarity on ReferenceError
anitahy73 Sep 21, 2026
8a38be1
Clarify comments on random number generation
anitahy73 Sep 21, 2026
6d264c2
Comment out console.log and add notes for debugging
anitahy73 Sep 21, 2026
2e91aea
Clarify error message and variable reassignment comments
anitahy73 Sep 21, 2026
b48ce39
Refine comments in 2-time-format.js for better understanding
anitahy73 Sep 22, 2026
f35bfdc
Improve comments for pence to pounds conversion
anitahy73 Sep 22, 2026
3a5af8c
Update comments for error identification in percentage change
anitahy73 Sep 22, 2026
c2075ba
Clean up comments in 3-to-pounds.js
anitahy73 Sep 22, 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
4 changes: 3 additions & 1 deletion Sprint-2/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ let count = 0;
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
// Describe whaWt line 3 is doing, in particular focus on what = we calculate the value of sum operator and put it in left variable.


7 changes: 6 additions & 1 deletion Sprint-2/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ 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.
let initials =
`${firstName.charAt(0)}` +
`${middleName.charAt(0)}` +
`${lastName.charAt(0)}`;

console.log(initials);

const initials = ``;

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

const dir = ;
const ext = ;

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

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

// 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
// In this exercise, you will need to work out what num represents?It gives us a random number between 1-100
// Try breaking down the expression and using documentation to explain what it means? + minimum shifts it between 1-100 so the minimum number is 1 and the biggest one is 100
//Math.random gives us a random number between 0-1 and the next parantecec returns 100
//after that we multiple these two given values between 0-100 and the floor methode rounds down the given value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Math.floor, the number is from 0 to 99. What does + minimum do next? What is the smallest num can be, and the biggest?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, 1 to 100. Good.

// 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
4 changes: 2 additions & 2 deletions Sprint-2/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
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 put back slash to change it into comments.
3 changes: 2 additions & 1 deletion Sprint-2/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 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)
5 changes: 3 additions & 2 deletions Sprint-2/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Currently trying to print the string "I was born in Bolton" but it isn't working...
// what's the error ?
// what's the error?
//ReferenceError: Cannot access 'cityOfBirth' before initialization

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);
6 changes: 3 additions & 3 deletions Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);

const last4Digits = String(cardNumber).slice(-4);
console.log(last4Digits);
// 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
// Before running the code, make and explain a prediction about why the code won't work?this function works on string NOT numbers
// 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
4 changes: 2 additions & 2 deletions Sprint-2/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
const twelveHourClockTime = "8:53pm";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your fix runs. Now add the error.

The prep shows three error names: SyntaxError, TypeError and ReferenceError. Which one was it here? And why did it happen?

const twentyFourHourClockTime= "20:53";
27 changes: 24 additions & 3 deletions 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 @@ -11,12 +11,33 @@ console.log(`The percentage change is ${percentageChange}`);

// Read the code and then answer the questions below

// a) How many function calls are there in this file? Write down all the lines where a function call is made
// a) How many function calls are there in this file? Write down all the lines where a function call is made?
//There are 5 function calls:
//replaceAll
//Line 4
//Number(...)
//Line 4
//priceAfterOneYear.replaceAll(",", "")
//Line 5
//Number(...)
//Line 5
//priceAfterOneYear.replaceAll(",", "")
//Line 10 ,console.log

// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?

//error:line 5,SyntaxError: missing ) after argument list,missing a comma between the two arguments.
// c) Identify all the lines that are variable reassignment statements
//carPrice = Number(carPrice.replaceAll(",", ""));
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));


// d) Identify all the lines that are variable declarations
//let carPrice
//let priceAfterOneYear
//const priceDifference
//const percentageChange

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//it removes all commas from the string
//converts the string "10000" into the number 10000
//The purpose is to turn the price from a formatted string into a number
23 changes: 18 additions & 5 deletions Sprint-2/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@ console.log(result);

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

// a) How many variable declarations are there in this program?
// a) How many variable declarations are there in this program?6

// b) How many function calls are there?
// b) How many function calls are there?1

// c) Using documentation, explain what the expression movieLength % 60 represents
// c) Using documentation, explain what the expression movieLength % 60 represents?
//8784 % 60=24
//The % operator is called the remainder operator.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explains % in general. What does movieLength % 60 mean in this program? It is 24 here. 24 what?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 24 seconds. Good.

//It gives you the remainder left over after division.
//we can calculate the number of the left seconds after converting the movie length into whole minutes, 24 seconds left over after converting the movie's total length into whole minutes.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?This removes the seconds that don't make up a complete minute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the first half. What does dividing by 60 give you after that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, 146 minutes.

//Then it divides that number by 60 to convert the seconds into whole minutes.
//we have 8784 seconds so

// e) What do you think the variable result represents? Can you think of a better name for this variable?
//8784 - 24 = 8760
//8760 / 60 = 146 it is the total minutes

// e) What do you think the variable result represents? Can you think of a better name for this variable?creates a formatted representation of the movie's length in hours, minutes, and seconds.
//I can name it the movie duration
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
//Works properly for non-negative whole-number seconds; decimals/negative values cause formatting problems



13 changes: 11 additions & 2 deletions Sprint-2/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ console.log(`£${pounds}.${pence}`);

// You need to do a step-by-step breakdown of each line in this program
// Try and describe the purpose / rationale behind each step
//this function penceString.length-1 removes the last p from string so it values 3 because it contains 4 characters minues 1.
//penceString.substring(0, 3) and it takes the characters from position 0 up to, but not including, position 3.
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters.
//const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
//This line extracts the pounds part.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 27 and line 28 repeat the same code. Keep one. Then keep going. What do lines 14 to 16 give for pence? What does padEnd do there? And what does line 18 print?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your pence steps are right now, and £3.99 is correct.

Lines 27 and 28 still repeat the same code. Delete line 27.

//line14:penceString = "399p"

//paddedPenceNumberString is "399".
//The substring() takes the last two characters, so:"399" → "99"
//Then .padEnd(2, "0") checks the string is at least 2 characters long. If it already has 2 characters, like "99", without changing the rest.
//padEnd(2, "0") adds "0" to the end of the string until it reaches a length of 2 and finally line 18 prints the result which is £3.99

// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
5 changes: 3 additions & 2 deletions Sprint-2/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Let's try an example.
In the Chrome console, invoke the function `alert` with one argument, the string `"Hello world!"`;

What effect does calling the `alert` function have?
alert() is a function that displays a message to the user.its return value is undefined.

Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`.

What effect does calling the `prompt` function have?
What is the return value of `prompt`?
What effect does calling the `prompt` function have?It provides a text box where the user can enter their name, along with buttons such as OK and Cancel.
What is the return value of `prompt`? prompt() returns a value.