Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6626e33
add a comment to answer the question for sprint1
Tobias-Amaechina Jun 18, 2026
268fe9a
using Template literal concept
Tobias-Amaechina Jun 19, 2026
a55b982
adding the quotation inside the backtick
Tobias-Amaechina Jun 19, 2026
466a1ad
Using slice function to add arrays of string from first to the last s…
Tobias-Amaechina Jun 20, 2026
90d852d
using lastIndesOf to locate last dot in arrays and assign it to lasdo…
Tobias-Amaechina Jun 20, 2026
ac380be
using slice method to add the extention of filename to the ext variable
Tobias-Amaechina Jun 20, 2026
be73fdd
using console method to log the details of dir and ext
Tobias-Amaechina Jun 20, 2026
ad02c56
breaking done what Math.random method is doing
Tobias-Amaechina Jun 20, 2026
fef3716
explaing what the (maximum -minimum +1 ) is doing with respect to the…
Tobias-Amaechina Jun 20, 2026
0589943
explain what step 3 is doing with respect to Math.random()*(maximum-…
Tobias-Amaechina Jun 20, 2026
df3dd3b
Explains what step 4 math.floor (..) was doing
Tobias-Amaechina Jun 20, 2026
ae416a6
Explained what the entire expression on the right hand side was doing
Tobias-Amaechina Jun 20, 2026
5267ace
step 5 explains what num stands for
Tobias-Amaechina Jun 20, 2026
599cfbd
used multiple comment syntax to coment out the strings
Tobias-Amaechina Jun 20, 2026
59a1f60
declaring a variable with Const key word doesn't allow reassigning s…
Tobias-Amaechina Jun 20, 2026
1f1249d
the Varible was being access from the TDZ
Tobias-Amaechina Jun 20, 2026
9dad574
the varible has been hoisted and initialled before accessing
Tobias-Amaechina Jun 20, 2026
94df850
commenting out the first code to avoid SyntaxError
Tobias-Amaechina Jun 20, 2026
26c75aa
I predicted that it wouldn't work as slice method is used on a numbe…
Tobias-Amaechina Jun 20, 2026
7a6e15e
I printed the type of data type variable cardNumber is on the console…
Tobias-Amaechina Jun 20, 2026
e8a084e
commenting out the console.log(typeof cardNumber) before running the…
Tobias-Amaechina Jun 20, 2026
536afc3
fixing the error my converting the number to string by putting doubl…
Tobias-Amaechina Jun 20, 2026
aec02fc
Identifier cannot start with a number,must start with a leter , _ or …
Tobias-Amaechina Jun 20, 2026
224b857
the second varible was updated to start with underscore
Tobias-Amaechina Jun 20, 2026
fab2124
added the missing comma to correct the error
Tobias-Amaechina Jun 20, 2026
0183466
answered question on Variable reasignment lines
Tobias-Amaechina Jun 20, 2026
69966b3
answered queation about variable declration
Tobias-Amaechina Jun 20, 2026
9a0c788
Answerd the question e about what the expression is doing
Tobias-Amaechina Jun 20, 2026
cb291d0
Answered question on how many variable delaration are in the file
Tobias-Amaechina Jun 21, 2026
0eada55
Answered question on how many function calls are in the program
Tobias-Amaechina Jun 21, 2026
5d2e5f9
Answered question on modulo Operation
Tobias-Amaechina Jun 21, 2026
9a422af
Answered question on what line 4 is doing
Tobias-Amaechina Jun 21, 2026
0d1fd04
Answered question on what the varible result represents and the bet…
Tobias-Amaechina Jun 21, 2026
b1a87d4
Answered question about if the code will work for all values
Tobias-Amaechina Jun 21, 2026
e6184ac
Describe the purpose and rational of step 2
Tobias-Amaechina Jun 21, 2026
9b3dbab
answered the purpose and rationale of line 8
Tobias-Amaechina Jun 21, 2026
ac91e9c
explains the .padStart method in context
Tobias-Amaechina Jun 21, 2026
cdf22c6
explained the step 9 and it's rationale
Tobias-Amaechina Jun 21, 2026
564b749
answered question and rationale of line 14 code
Tobias-Amaechina Jun 21, 2026
bb30402
explained the purpose of line 18 and it's rational
Tobias-Amaechina Jun 21, 2026
771b9ec
Answered question about invoking Alert for chrome.md file
Tobias-Amaechina Jun 21, 2026
56ee0b7
Answered question on the effect of prompt function in chrome.md file
Tobias-Amaechina Jun 21, 2026
68c6a1f
Answered question about console.log on object.md file
Tobias-Amaechina Jun 21, 2026
5720fea
updated the right ouput for console.log
Tobias-Amaechina Jun 21, 2026
5a6e439
answered question of the output of console in the consoledevtool
Tobias-Amaechina Jun 21, 2026
345ae8e
Answered question what I got when typed typeof console in Devtool c…
Tobias-Amaechina Jun 21, 2026
9bd9215
Answered question about what console stores in Object.md file
Tobias-Amaechina Jun 21, 2026
9460b09
answered the question about console.log and console.assert in object.…
Tobias-Amaechina Jun 21, 2026
43a607c
I predicted and explain what will happen in the code when run
Tobias-Amaechina Jun 21, 2026
4f0bc34
wrote what my prediction will look like
Tobias-Amaechina Jun 21, 2026
5734386
call the function capitalise with a string 'tobias'
Tobias-Amaechina Jun 21, 2026
aa18722
interpreted the error and gave my explanation of the reason the erro…
Tobias-Amaechina Jun 21, 2026
a1ca363
added two ways the error can be fixed
Tobias-Amaechina Jun 21, 2026
67b7b3e
interpreted the error generated and suggested two ways to fix the e…
Tobias-Amaechina Jun 21, 2026
90a79fc
mistakenly deleted the original function , and now get it restored
Tobias-Amaechina Jun 21, 2026
3465118
wrote a new code and comment out the original code
Tobias-Amaechina Jun 21, 2026
82db135
console.log the function by passing tobias as arguement and see it o…
Tobias-Amaechina Jun 21, 2026
90414e0
predicted and explained what will happen when the code is run
Tobias-Amaechina Jun 22, 2026
da1decc
Answered question about why an error will occur when the program is …
Tobias-Amaechina Jun 22, 2026
9b41b32
tried playing compute and pasted what happened as SyntaxError: Ident…
Tobias-Amaechina Jun 22, 2026
bbc856e
The double qoute was removed to make the value for cardNumber as Num…
Tobias-Amaechina Jun 24, 2026
e969a10
using '.toString()' method to cast the data type number to string an…
Tobias-Amaechina Jun 24, 2026
be7f385
the '.slice()' method was then used to extract the the last 4 digit …
Tobias-Amaechina Jun 24, 2026
01dd4fd
firstly explained what the naming convention I used earlier denote i…
Tobias-Amaechina Jun 24, 2026
264a822
explain best practices used in naming variable in JavaScript
Tobias-Amaechina Jun 24, 2026
3503a51
applied the naming convention to the first variable
Tobias-Amaechina Jun 24, 2026
25a5ac8
applied the naming convention to the second variable
Tobias-Amaechina Jun 24, 2026
be4e495
Added more context and specically refer to the terms in the blank wi…
Tobias-Amaechina Jun 24, 2026
9beb850
remove Sprint-2 files
Tobias-Amaechina Jun 24, 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 line 3 is updating the value of the count variable. The `=` operator is an assignment operator that takes the value on the right side (which is `count + 1`, meaning the current value of count plus 1) and assigns it to the variable on the left side (which is `count`). This effectively increments the value of count by 1.

4 changes: 2 additions & 2 deletions Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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]}"`;
Comment on lines 6 to +8

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.

Note: Usually the double quotes surrounding a string are not part of the sting value; they are only used to indicate the boundary of the string.

No change needed.

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.

Noted , Thanks


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

console.log(initials); // Output: "CKJ"
9 changes: 7 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,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 = ;
const dir = filePath.slice(0, lastSlashIndex);
const lastDot = filePath.lastIndexOf(".");
const ext = filePath.slice(lastDot);

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
8 changes: 8 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Sprint-1/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?*/
3 changes: 2 additions & 1 deletion Sprint-1/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);
9 changes: 8 additions & 1 deletion Sprint-1/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// 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}`);

/*console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";*/
/* The error is that the variable `cityOfBirth` is being used before it is declared and assigned a value. In JavaScript, variables declared with `const` (or `let`) are not hoisted in the same way as `var`, so you cannot access them before their declaration. To fix this, you should declare and assign the variable before using it in the `console.log` statement:*/
//The variable were being accessed from the Temporal Dead Zone (TDZ) before it was declared and assigned a value. In JavaScript, variables declared with `const` (or `let`) are not hoisted in the same way as `var`, so you cannot access them before their declaration. To fix this, you should declare and assign the variable before using it in the `console.log` statement:

const cityOfBirth = "Bolton";

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

const last4Digits = cardNumberStr.slice(-4);
console.log(last4Digits); // Output: "4213"

// 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
// I suspect the code doesn't work because the slice method is being called on a number, but slice is a method for strings. Therefore, I predict that the code will throw an error saying that slice is not a function for numbers.

// i console the typeof cardNumber and it returns number


9 changes: 7 additions & 2 deletions Sprint-1/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 twelveHourClockTime = "8:53pm";
const twentyFourHourClockTime = "20:53";
/*names beginning with $ or _ often carry special conventions:
_name often implies a private/internal variable.
$name is commonly associated with libraries like jQuery or special framework objects.*/
/*For ordinary variables, it's usually clearer to start with a letter and use camelCase and avoid special characters, not starting with a number. and choosing meaningful names that describe the variable's purpose.*/
23 changes: 21 additions & 2 deletions Sprint-1/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 @@ -12,11 +12,30 @@ 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
// There are 5 function calls in this file. The function calls are made on the following lines:
// Line 1: replaceAll()
// Line 2: replaceAll()
// Line 5: Number()
// Line 6: Number()
// Line 9: 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?

// 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 occurring on line 5., and it's a SyntaxError: missing , The error is due to a missing comma in the replaceAll() method.//The error occurs on line 5. A SyntaxError is thrown because a comma is missing between the two arguments passed to the replaceAll() method. JavaScript uses commas to separate arguments in a function call. The programming term that belongs to the blank is call arguments as that is the actual value passed during a function call. The correct syntax should be replaceAll(",", ""). To fix this problem, we need to add the missing comma in the replaceAll() method on line 5
// c) Identify all the lines that are variable reassignment statements
// The variable reassignment statements are on the following lines:
// Line 4: carPrice = Number(carPrice.replaceAll(",", ""));
// Line 5: priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ,""));

// d) Identify all the lines that are variable declarations
// The variable declaration statements are on the following lines:
// 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;
// A declaration is when a variable is created, using let or const.



// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
/* The expression Number(carPrice.replaceAll(",","")) is converting the string value of carPrice, which contains a comma, into a number. The replaceAll() method is used to remove all commas from the string, and then the Number() function is used to convert the resulting string into a number. This allows for mathematical operations to be performed on the value of carPrice without any issues caused by the presence of commas in the string.*/
18 changes: 18 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,32 @@ 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?
// There are 6 variable declarations in this program. The variable declarations are on the following lines:
// Line 1: const movieLength = 8784;
// Line 3: const remainingSeconds = movieLength % 60;
// Line 4: const totalMinutes = (movieLength - remainingSeconds) / 60;
// Line 6: const remainingMinutes = totalMinutes % 60;
// Line 7: const totalHours = (totalMinutes - remainingMinutes) / 60;
// Line 9: const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;


// b) How many function calls are there?
// There is 1 function call in this program. The function call is made on the following line:
// Line 10: console.log(result);


// c) Using documentation, explain what the expression movieLength % 60 represents
// The expression movieLength % 60 represents the remainder of the division of movieLength by 60. In this case, it calculates the number of seconds remaining after converting the total length of the movie (in seconds) into minutes. The modulo operator (%) is used to find the remainder when one number is divided by another. So, if movieLength is 8784 seconds, movieLength % 60 will give us the number of seconds that do not make up a full minute.

// 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?
// The expression assigned to totalMinutes calculates the total number of minutes in the movie length. It does this by first subtracting the remaining seconds (calculated in line 3) from the total movie length (movieLength), which gives us the total number of seconds that can be fully converted into minutes. Then, it divides that result by 60 to convert those seconds into minutes. This gives us the total number of complete minutes in the movie length, excluding any remaining seconds.

// 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 string that shows the total length of the movie in hours, minutes, and seconds. A better name for this variable could be "formattedMovieLength" or "movieDuration" to more clearly indicate that it holds the duration of the movie in a human-readable format.

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
/* The code will work for all non-negative integer values of movieLength, as it correctly calculates the hours, minutes, and seconds for any given length of time in seconds. However, if movieLength is a negative number or a non-integer value, the code may not produce meaningful results. For example, if movieLength is negative, the calculations for remainingSeconds, totalMinutes, and totalHours will not make sense in the context of a movie duration. Additionally, if movieLength is a non-integer (like a float), the calculations may yield unexpected results due to how JavaScript handles floating-point arithmetic. Therefore, it's best to ensure that movieLength is a non-negative integer for this code to work correctly. Also, it works correctly only when the movieleng is less than 24 hours, because the code does not account for days. If the movie length exceeds 24 hours, the totalHours variable will continue to increase without resetting after 24, which may not be the desired behavior for representing time in a standard format. */
// if movieLength = 90000 seconds, that 25 hours , the variable result will be 25:0:0, which is not a standard representation of time.
// leading zeros , the variable result will always output resuls like H:M:S instead of HH:MM:SS, so if the movie length is 1 hour, 5 minutes and 9 seconds, the variable result will be 1:5:9 instead of 01:05:09.
7 changes: 7 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,10 @@ 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): removes the trailing "p" from the pence string to isolate the numeric value.
//3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensures that the numeric value has at least three digits by padding with 3 leading zeros if necessary, .padStart(target Length, padString), adds strings to the start of the string until it reaches the target length, in this case 3, and if the string is already 3 or more characters long, it will not add any padding.
/*4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds portion of the price ,paddedPenceNumberString.length =3, so paddedPenceNumberString.length - 2 = 1, so paddedPenceNumberString.substring(0, 1) = "3" it took characters from index 0 to 1*/
/*5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence portion of the price and ensures it has two digits by padding with a trailing zero if necessary, paddedPenceNumberString.length =3, so paddedPenceNumberString.length - 2 = 1, so paddedPenceNumberString.substring(1) = "99" it took characters from index 1 to the end of the string, then .padEnd(2, "0") adds strings to the end of the string until it reaches the target length, in this case 2, and if the string is already 2 or more characters long, it will not add any padding.*/

/*6. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console, using template literals to insert the pounds and pence variables into the string. The output will be in the format "£X.YY", where X is the pounds value and YY is the pence value. In this case, it will output "£3.99".*/

4 changes: 4 additions & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ Let's try an example.
In the Chrome console,
invoke the function `alert` with an input string of `"Hello world!"`;


What effect does calling the `alert` function have?
// By invoking alert("Hello world!"); the effect it has is that a small modal dialog box pops up at the top of the window browser displaying Hello world!, along with an OK button.

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?
//The effect is similar to the alert one a small modal dialog box pops up with the addition of a text input field and two buttons for 'OK' and 'Cancel', it displays the question What is your name?
What is the return value of `prompt`?
//The return value of the 'prompt' depends on what action the client did , whci is one of two things based on the client actions.it will return whatever the client typed into the text field as string and click 'OK' and this will be stored in the variable myName, and can be verified by typing myName into the console and hitting ENTER.However if the user clicks cancel , it returns null.
85 changes: 84 additions & 1 deletion Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,96 @@ In this activity, we'll explore some additional concepts that you'll encounter i

Open the Chrome devtools Console, type in `console.log` and then hit enter

What output do you get?
What output do you get? // I got 'console.log'
// ƒ log() { [native code] }

Now enter just `console` in the Console, what output do you get back?
/*console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}
assert
:
ƒ assert()
clear
:
ƒ clear()
context
:
ƒ context()
count
:
ƒ count()
countReset
:
ƒ countReset()
createTask
:
ƒ createTask()
debug
:
ƒ debug()
dir
:
ƒ dir()
dirxml
:
ƒ dirxml()
error
:
(...n)=> {…}
group
:
ƒ group()
groupCollapsed
:
ƒ groupCollapsed()
groupEnd
:
ƒ groupEnd()
info
:
ƒ info()
log
:
ƒ log()
memory
:
MemoryInfo {totalJSHeapSize: 33100000, usedJSHeapSize: 29400000, jsHeapSizeLimit: 3760000000}
profile
:
ƒ profile()
profileEnd
:
ƒ profileEnd()
table
:
ƒ table()
time
:
ƒ time()
timeEnd
:
ƒ timeEnd()
timeLog
:
ƒ timeLog()
timeStamp
:
ƒ timeStamp()
trace
:
(...n)=> {…}
warn
:
(...n)=> {…}
Symbol(Symbol.toStringTag)
:
"console"*/

Try also entering `typeof console`
// got: object

Answer the following questions:

What does `console` store?
/* Console is a globally available Object provided by the browser environment to store debugging tools functions in one convienient place*/
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
/*`console.log` or `console.assert` mean? i.e console.log go inside the console Object and print out whatever you have on the console to see, log() is a method which does the action on the object , and for console.assert means check whether something is true and if it's not true show the error message on the console. the '.' is called the property accessor or dot Notation and what it does is to dig inside an object and grab a specific piece of data or functionality stored within it.*/
13 changes: 0 additions & 13 deletions Sprint-2/1-key-errors/0.js

This file was deleted.

20 changes: 0 additions & 20 deletions Sprint-2/1-key-errors/1.js

This file was deleted.

Loading
Loading