Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
704f58f
added a comment explaining the role of the = .
TTiamiyu Jun 13, 2026
dc17501
Implemented the function to get the initials as output without writin…
TTiamiyu Jun 13, 2026
dce53b5
Add dir and ext variable assignments in 3-paths.js
TTiamiyu Jun 13, 2026
cecb6ba
added a "for" statement, for random number generation to log multiple…
TTiamiyu Jun 15, 2026
bbfef51
Added comments to explain code execution prevention and commenting me…
TTiamiyu Jun 15, 2026
274fe16
Change age variable declaration from const to let for reassignment
TTiamiyu Jun 15, 2026
63265cb
Fix console log placement to correctly print city of birth
TTiamiyu Jun 15, 2026
e6db536
Fix card number assignment to string for correct slicing of last 4 di…
TTiamiyu Jun 15, 2026
1c5023d
Fix variable naming for twelve and twenty-four hour clock time
TTiamiyu Jun 16, 2026
b06aae3
Add comments to clarify function calls, variable assignments, and err…
TTiamiyu Jun 16, 2026
496d1b8
Enhance comments for clarity on variable declarations, function calls…
TTiamiyu Jun 16, 2026
32d7119
Enhance comments to provide a detailed step-by-step explanation of th…
TTiamiyu Jun 16, 2026
5e06e8c
Add results section to document outcomes of alert and prompt function…
TTiamiyu Jun 16, 2026
7503415
Add outputs and answers for console exploration activity
TTiamiyu Jun 16, 2026
ebaef49
Added '//' to commenting out my response.
TTiamiyu Jun 26, 2026
6afaba2
Declared initials with 'let' statement inside function.
TTiamiyu Jun 26, 2026
ebbbb71
Fix dir and ext variable assignments in file path extraction
TTiamiyu Jun 26, 2026
23af249
Update comment formatting to use multi-line comment style for clarity
TTiamiyu Jun 26, 2026
ca8a1e2
Comment out original code and predictions for clarity in error explan…
TTiamiyu Jun 26, 2026
8977bb2
Update comments to clarify potential issues with movieLength input va…
TTiamiyu Jun 26, 2026
aa69c9f
Clarify error explanation in comments regarding missing comma in pric…
TTiamiyu Jun 26, 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
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

// The = served as the executer of the assignment operation.
15 changes: 10 additions & 5 deletions Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// 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 firstName = "Creola";
let middleName = "Katherine";
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 = ``;
function getInitials() {
let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`;
return initials;
}

// https://www.google.com/search?q=get+first+character+of+string+mdn
console.log(getInitials());

// Export the initials for testing instead of returning at top-level
module.exports = getInitials;
8 changes: 5 additions & 3 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ 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 = ;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Think of ways to use slice method extract and store directory part and extension part in the variable dir and ext respectively.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for your review, i have infused the .slice method and i have used the console.log to recall the answer to 'dir' and 'ext', rather than manually inputting it.

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

// https://www.google.com/search?q=slice+mdn
console.log(`The dir part of ${filePath} is ${dir}`);
console.log(`The ext part of ${filePath} is ${ext}`);
// https://www.google.com/search?q=slice+mdn
5 changes: 4 additions & 1 deletion Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const minimum = 1;
const maximum = 100;

const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
for (let i = 0; i < 5; i++) {
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
console.log(num);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have done a good job of using for loop to log the value of variable num.

  1. Can you write what was your finding based on it.

  2. What do you think the range of the output will be ?

  3. Try mentioning the functionality of different function used here like Math.random() , Math.floor()


// 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
Expand Down
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?

/* To prevent the computer from executing these lines of code, you can comment them out,
you can use `//` for single-line comments or `/* */` for multi-line comments, like i demonstated above.
2 changes: 1 addition & 1 deletion Sprint-1/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// trying to create an age variable and then reassign the value by 1

const age = 33;
let age = 33;
age = age + 1;
2 changes: 1 addition & 1 deletion Sprint-1/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 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}`);
17 changes: 15 additions & 2 deletions Sprint-1/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
//const cardNumber = 4533787178994213;
//const last4Digits = 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

//PREDICTION:
//the code wont work because the card number isnt in ("") and the computer wont be able to apply the .slice due to this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It is good practice to use single line comment or multiline comment whenever required.

try looking for lines which needs to be ignored by computer in the code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I see what you mean and i have commented out the headings i created earlier.


//THE ERROR:
//cardNumber.slice is not a function

//YES! the error is what i predicted.

//FIX:
const cardnumber = "4533787178994213";
const last4Digits = cardnumber.slice(-4);
console.log(last4Digits);
7 changes: 5 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
const twelveHourClockTime = "8:53pm";
const twentyFourHourClockTime = "20:53";

//The Error:
//The code would not run because only a letter can follow the 'const' and 'let' declarations in javascript.
15 changes: 15 additions & 0 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ 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
//1. Line 5: carPrice.replaceAll(",", "")
//2. Line 6: priceAfterOneYear.replaceAll(",", "")
//3. Line 8: console.log(`The percentage change is ${percentageChange}`)

// 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?
//The error is in line 5, the error is occurring because "comma missing "," and "" for priceAfterOneYear.replaceAll("," "") function call.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of writing comma is missing here, we can put it like "Comma is missing "," and "" for priceAfterOneYear.replaceAll("," "") function call.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Your suggestion is better and i have incorporated it, thank you.

// 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 = "10,000";
//let priceAfterOneYear = "8,543";
//const priceDifference = carPrice - priceAfterOneYear;
//const percentageChange = (priceDifference / carPrice) * 100;


// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//The expression is converting the string representation of the car price to a number by first removing the comma.

//Purpose:
//To allow the computer identify the value of the car price as a number so that it can be used in calculations.
19 changes: 19 additions & 0 deletions Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,33 @@ 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?
//1.movieLength
//2.remainingSeconds
//3.totalMinutes
//4.remainingMinutes
//5.totalHours
//6.result

// b) How many function calls are there?
//1. Line 10: console.log(result)

// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

//The % symbol is called the modulus operator. It returns the remainder of a division operation.
// In this case, movieLength % 60 calculates the remaining seconds after dividing the total movie length by 60 (the number of seconds in a minute).
// This gives us the number of seconds that do not make up a full minute in the movie length.

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
// The expression (movieLength - remainingSeconds) / 60 calculates the total number of minutes in the movie by subtracting the remaining seconds from the total seconds
// and then dividing by 60.

// e) What do you think the variable result represents? Can you think of a better name for this variable?
// The variable result represents the formatted time of the movie in hours, minutes, and seconds. A better name for this variable could be movieDuration.

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
//It will do the math perfectly for most normal positive numbers, but there are a few situations where the code will act wierdly.
//1. The "Single Digit" Visual Bug (Zero-Padding)
//2. Negative numbers
//3.Decimal numbers (floats and non integers)
//4. invalid data types (like strings, objects, etc.)
16 changes: 16 additions & 0 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@ 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): This removes the letter 'p' from the end of the string,
// leaving just the numbers part of the string. The substring method is used to extract a portion of the string,
// starting from index 0 and ending at the second-to-last character (length - 1).

// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); This is to ensure the numbers presented after the substring is at least 3 characters long,
// if the number is shorter the computer would add '0' or '0's in front of the number to make it 3 digits long.

// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2):
// This extracts the pounds part of the string by taking all characters except the last two.

// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
// This extracts the pence part of the string by taking the last two characters and ensures that it is at least 2 characters long by adding '0' at the end
// if necessary as this is because we need the decimal value.

// 6. console.log(`£${pounds}.${pence}`): This outputs the final answer in the format of pounds and allows the user to see the final result also.
8 changes: 8 additions & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ Now try invoking the function `prompt` with a string input of `"What is your nam

What effect does calling the `prompt` function have?
What is the return value of `prompt`?

MY RESULTS:

After running the alert function the browser to immediately open a pop up box at the top of the screen displaying what i inputted 'Hello World!'.

After running the prompt 'let myName = prompt("what is your name") the browser opened a pop up window that allowed me to type in my name and it was saved after clicking OK.

Running the 'prompt' "myName" the browser displayed the name i inputted in the console immediately.
12 changes: 12 additions & 0 deletions Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ Answer the following questions:

What does `console` store?
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?

OUTPUTS
`console.log` came back as ƒ log() { [native code] } after hitting enter

`console` came back as console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}

typeof console came back as 'object'

ANSWERS
The console stores a collection of functions and data that allow javascript code to interact with the browser's debugging tools

The "." is known as a property accessor, it acts as a bridge telling the javascript to look inside the object on the left to find a specific item on the right.
Loading