Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2d1b73d
Update code from 26-ITP-MAY to 26 ITP-SEP for resubmitting
Sep 2, 2026
21df038
validate error with w3.org
Sep 3, 2026
2753312
Lables and input and css created
May 16, 2026
56c0cf5
Style seprated from html and contained in its own file.
May 30, 2026
148a95a
add regex to name label
Sep 7, 2026
406e215
update name
Sep 7, 2026
b9b3c99
update align author name centre
Sep 7, 2026
a2f9b70
link css file
Sep 7, 2026
06cd821
remove duplicate css file
Sep 7, 2026
05ec57a
Centre submit button
Sep 7, 2026
a6af01c
Add css validation icon display
Sep 7, 2026
e41c304
Describe line 3 code
Sep 7, 2026
d3a57b0
Update answer
Sep 7, 2026
c302bc4
Implement charAt method
Sep 7, 2026
e43b31e
Create variable using slice method
Sep 8, 2026
9a013e1
Explain how the code works
Sep 8, 2026
439f732
Comment out non code comments
Sep 8, 2026
ed79f77
Reassign age variable
Sep 8, 2026
28e7901
Initialize variable first
Sep 8, 2026
50b1516
Fix data type
Sep 8, 2026
209739c
Fix variable name declaration
Sep 8, 2026
a613e4c
Answer question. Fix code. Add comma.
Sep 8, 2026
fbade85
Answer question and explain.
Sep 10, 2026
ee0394d
Explain how the program work
Sep 10, 2026
b3f5ce4
Explain code step by step.
Sep 11, 2026
19404bf
Questions answered about alert and prompt on chrome
Sep 11, 2026
47c46d3
Answer questions on console object
Sep 11, 2026
59a3ca0
Format answers with numbers.
Sep 11, 2026
171051e
Format answers with numbers.
Sep 11, 2026
e0505a8
Merge branch 'CodeYourFuture:main' into coursework/sprint-2
russom-g Sep 11, 2026
329b172
Remove Form-Controls files from sprint-2 branch
Sep 11, 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-2/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

// On line 3 is the = sign is an assignment operator and it is assigning thr count + 1 expression into the count variable.
2 changes: 1 addition & 1 deletion Sprint-2/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ 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 = ``;
const initials = `${firstName.charAt()}${middleName.charAt()}${lastName.charAt()}`;

// https://www.google.com/search?q=get+first+character+of+string+mdn
7 changes: 5 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,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 = ;
const ext = ;
const dir = filePath.slice(0, lastSlashIndex);
const ext = filePath.slice(-3);

console.log(dir);
console.log(ext);

// https://www.google.com/search?q=slice+mdn
7 changes: 7 additions & 0 deletions Sprint-2/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// 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

// 1. num is a variable that stores the final result of the expression assigned to it.
// 2. The Math.random() method generates a random decimal number from 0 up but not excluding 1.
// 3. The Math.floor() method round a decimal number down to a whole number.
// 4. (maximum - minimum + 1) calculates how many possible whole numbers there are.
// Java Script evaluates the expressions inside the inner parentheses first.
// + minimum adds 1 to move the range from 0 to the minimum 1.
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?
2 changes: 1 addition & 1 deletion Sprint-2/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;
4 changes: 3 additions & 1 deletion Sprint-2/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// 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}`);

// Java script cannot access the variable cityOfBirth before initialization.
9 changes: 8 additions & 1 deletion Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
const last4Digits = Number(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

// Prediction: slice() is a string method. That is why it is not working on numbers.
// Error message: type error
// Convert the number to string
// If we need to keep number we need to convert it back from string to number using Number() method
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";

// Variable names cannot start with a number in Java Script.
15 changes: 14 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,16 @@ 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?

// Answers

// a) There are no function or function calls in this code.

// b) The error was online 5 inside replaceAll method parentheses a comma is missing between the double quotes.

// c) Line 4 carPrice. Line 5 priceAfterOneYear.

// d) Line 1, 2, 7 and 8.

// e) The method replaceALL is removing the comma. Then the Number method is converting the string into numbers.
// The purpose is to use number operations and calculate the percentage change.
14 changes: 14 additions & 0 deletions Sprint-2/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ 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

// Answers

// a) There are 6 variable declarations.

// b) There are no function calls.

// c) The reminder (%) operator returns the reminder left over when one operand is divided by a second operand.

// d) movieLength(8784) - remainingSeconds(24) = 8760(seconds). 8760 / 60 gives us 146 minutes. totalMInutes = 146

// e) result represents the length of the movie in hours, minutes, and seconds format. It can be renamed movieDuration.

// f) When displaying single digit hour, minute, or seconds it doesn't include 0 in front of the digit.
35 changes: 24 additions & 11 deletions Sprint-2/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
const penceString = "399p";

const penceStringWithoutTrailingP = penceString.substring(
0,
penceString.length - 1
);
const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1);

const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
);
const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);

const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");
const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");

console.log(`£${pounds}.${pence}`);

Expand All @@ -25,3 +17,24 @@ console.log(`£${pounds}.${pence}`);

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

// Answers

// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1):
// the substring() method returns the characters starting at index 0(3) up to and excluding the end(9) of penString variable.
// This way only 399 is extracted of the string. Then the result is assigned to penceStringWithoutTrailingP variable.

// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"):
// The method padStart(3, "0") adds the string 0 before if the length of penceStringWithoutTrailingP string is less than 3 characters.
// It then assign it to paddedPenceNumberString variable. For example if the string is 11, it returns 011 or the string is 1, it returns 001.

// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2)
// Again the method substring() returns the characters starting at length 0 and removing the last two characters which are the pence(00).
// This gives us only the pounds value and it the assigned to the pounds variable.

// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"):
// substring method first returns the last two characters of the paddedPenceNumberString string.
// Then the padEnd() method adds a 0 if the length of the string is less than 2. Then it assigns it to pence variable.

// 6. console.log(`£${pounds}.${pence}`):
// Finally console.log prints the pounds and pence adding the the pound sign £ first using template literal as £3.99
8 changes: 8 additions & 0 deletions Sprint-2/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,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`?

Answer

1. 'alert' display a message on pop up window.

2. 'prompt' asks for an input of information.

3. 'prompt' return value is string.
15 changes: 15 additions & 0 deletions Sprint-2/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ Answer the following questions:

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


Answer

1. When 'console.log' entered it gave the output: 'Uncaught ReferenceError: consol is not defined'.

2. When 'console' entered it gave the output: 'console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}'.

4. 'console; stores object.

5. 'console.log' print/display a value.

6. 'console.assert' checks weather a condition is true or false.

7. '.' means access the value inside the object.
Loading