Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
df5f817
created a new branch feature/form-controls
simanongawuza Sep 15, 2026
48ae851
edited the footer and added my name
simanongawuza Sep 16, 2026
c31d05d
Added content in the form element
simanongawuza Sep 16, 2026
ec03354
created a javascript file
simanongawuza Sep 22, 2026
e652c13
Ran my first Hello world js
simanongawuza Sep 22, 2026
89f36e0
Fuc fact about me
simanongawuza Sep 22, 2026
72b8724
Declare and access variables
simanongawuza Sep 22, 2026
a66fb77
Comparing variables
simanongawuza Sep 22, 2026
b0f2d1e
Explaining errors
simanongawuza Sep 23, 2026
8d227cd
learning multiple possibilities for IF statements
simanongawuza Sep 23, 2026
b4c386b
created variable response "as the outcome"
simanongawuza Sep 23, 2026
127829d
change response from const to let variable
simanongawuza Sep 23, 2026
fbabe03
Explanation of incrementing a variables
simanongawuza Sep 24, 2026
a040e64
Declared initials variable to take 1st letters
simanongawuza Sep 24, 2026
4c87f27
created string method to extract dir and ext from path
simanongawuza Sep 24, 2026
d39bec0
Explained evaluated how the expression works
simanongawuza Sep 24, 2026
094f842
changed the const to let to allow reassigning
simanongawuza Sep 24, 2026
2623dbd
Make the cityOfBirth the first line before the console.log
simanongawuza Sep 24, 2026
7282345
Converted the number to a string before the slice method
simanongawuza Sep 24, 2026
a5ef875
Changed the variables from numbers not letters
simanongawuza Sep 24, 2026
5b6ddbd
corrected the error in line 5
simanongawuza Sep 24, 2026
4be47f2
Answered the questions
simanongawuza Sep 24, 2026
7d4af4e
Line by line explanation of the code
simanongawuza Sep 24, 2026
87f5865
Input javaScript code into the chrome console practice
simanongawuza Sep 25, 2026
9d0e267
Explaing console.log uses and properties
simanongawuza Sep 27, 2026
3195b56
Remove Sprint 1 Form-Control changes
simanongawuza Sep 27, 2026
4a49b92
accidental prep folder from PR
simanongawuza Sep 27, 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
3 changes: 3 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,6 @@ 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

// ANSWER
// In line 3, the value of 1 is added to the inital value of count which was 0, therefore the count value is being increasing by one each time the code runs and saves the new result into the count variable. The assignment operator "=" runs the everuthing on the right side and then store the result in the variable on the left hand side.
8 changes: 2 additions & 6 deletions Sprint-2/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ const firstName = "Creola";
const middleName = "Katherine";
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 = ``;

// https://www.google.com/search?q=get+first+character+of+string+mdn
const initials = `${firstName[0]}${middleName[0]}${lastName[0]}`;
console.log(initials);
4 changes: 2 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,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 = filePath.slice(filePath.lastIndexOf(".") + 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the definition in line 7, the . should also be part of file extension. Please fix it. Thank you.


// https://www.google.com/search?q=slice+mdn
8 changes: 7 additions & 1 deletion Sprint-2/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ 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

// ANSWER
// num represents a random whole number in the range 0 - 100.
// math.random gives a random decimal between 0 and 1.math floor rounds the value to a whole number.
// (maximum - minimum + 1) evaluates the total count of integers. (+ minimum )adds 1 to the outcome.
// The code starts by evaluating math.random then multiply that by the maximum, math.floor will then round that value into a whole number then finally adding minimum to get num.
Comment on lines +11 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While your description is correct, it would be better if having a bit of explanation. For example, what does it mean by gives a random decimal between 0 and 1 (or both 0 and 1 included as well), and what is the purpose of then multiply that by the maximum, etc. Please elaborate your answer (don't need to be long, just with a little bit clarity/detail/accuracy). Thank you.

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: 4 additions & 1 deletion Sprint-2/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// 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}`);
//Answer
// The console.log will be execued first because it is before the declared city variable.

const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);
7 changes: 6 additions & 1 deletion Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
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
// 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

// Explanation
// The string slice method does not apply to number variables, therefore the code will not run.
// The number must be changed to a string first.
6 changes: 4 additions & 2 deletions Sprint-2/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
const twelveHourClockTime = "8:53pm";
const twentyFourhourClockTime = "20:53";

// A variable name can not start with a number.
9 changes: 8 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 @@ -12,11 +12,18 @@ 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
// line 4, number() and replaceAll()
// line 5, number() and 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?
// The was a missing comma in line 5.

// c) Identify all the lines that are variable reassignment statements
// line 4 and line 5

// d) Identify all the lines that are variable declarations
// line 1,line 2, line 7, line 8

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
// The expression changes the string to a number and removes the comma. This makes it possible for Javascript to perform subtraction since it is no longer a string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A bit of English presentation here, should be ... removes the comma and changes the string to a number. This is because the expression is actually removing commas first before data type conversion, so it would be better to follow the same order of execution when describing it.

11 changes: 6 additions & 5 deletions Sprint-2/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ 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?

// 6, line1,3,4,6,7,9
// b) How many function calls are there?

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

// The modulo operator divides the movieLength in seconds by 60 and give the remainder
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?

// It calculates the total number of whole minutes in the movie by subtracting the remainingSeconds from the total movie then divides the answer by 60 to covert seconds to minutes.
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// This variable represents the movie duration in the form of hours:minutes:seconds. better name id duration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

duration may still be not clear enough because const movieLength = 8784; can also be a kind of duration. Can you think of a better name? Thank you.

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
// The code will run for all non negative whole number.
16 changes: 16 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,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 :Removes the letter p from the end of the string.
//);
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); : Makes sure that the string has at least 3 characters by adding zeros at the beginning if required.

// // const pounds = paddedPenceNumberString.substring(
// 0,
// paddedPenceNumberString.length - 2 :This takes the first digit of the number in pence since 100 pence = 1 pound therefore coverting pence to pounds
// );
Comment on lines +34 to +37

@hackertainment hackertainment Oct 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Again, this may just be English presentation. It "takes out (or remove) the last two digits" rather than "takes the first digit". There is a minor difference between the two angles to present the same thing. While the end result is the same, the explanation can be more accurate.


// const pence = paddedPenceNumberString
// .substring(paddedPenceNumberString.length - 2): Takes the pence which is the 2 numbers after the 1st number and ensures that it is exactly 2 digits long.
// .padEnd(2, "0");

// console.log(`£${pounds}.${pence}`); : Prints the final output string using the literal to combine currency symbol, pounds and the pence.
6 changes: 5 additions & 1 deletion Sprint-2/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ Just like the Node REPL, you can input JavaScript code into the Console tab and
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?
It created a pop up message in the broswer saying Hello world and 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?
It displays a pop up message in the browswer asking the user "What is your name?", it also inludes an OK and Cancel button

What is the return value of `prompt`?
I entered my Sima and clicked OK, so the return value is "Sima" which is stored as myName.
19 changes: 11 additions & 8 deletions Sprint-2/4-stretch-explore/objects.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Try not to modify the question formatting. This file is in markdown format so that the '##' and '`' should be preserved.

Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
## Objects

In this activity, we'll explore some additional concepts that you'll encounter in more depth later on in the course.

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

What output do you get?
It gives the expression : ƒ log() { [native code] }

Now enter just `console` in the Console, what output do you get back?

Try also entering `typeof console`
Now enter just console in the Console, what output do you get back?
It gives the expression: console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} with all the methods or functions that can be used for debugging.
Try also entering typeof console
It gives the string "object"

Answer the following questions:

What does `console` store?
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
What does console store?
It stores a list of methods that can used in the browser's developer tools.

What does the syntax console.log or console.assert mean? In particular, what does the . mean?
Console.log means that you are accessing the log method of the console object. The dot (.) is called the member access operator or dot notation, it is used to access methods inside an object. it tells javascript to look inside the object on the left to get the method on the right.
Loading