Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
269946f
Added comments covering form requirements
marscancode Sep 11, 2026
b2c7381
Added customer requirements comment
marscancode Sep 11, 2026
e289781
Added name validation to form
marscancode Sep 11, 2026
74a67c9
Added email validation to form
marscancode Sep 11, 2026
e25b334
Added colour selector validation to form
marscancode Sep 11, 2026
ec30f47
Added size selector valdation to form
marscancode Sep 11, 2026
8f87ed4
Finished t-shirt form validation
marscancode Sep 11, 2026
297191f
Refactored form using devtools and updated requirements
marscancode Sep 11, 2026
8497414
Updated form semantics
marscancode Sep 11, 2026
85aded1
added description of code on line 3
marscancode Sep 17, 2026
c8979e7
declared variable that stores first character of each string
marscancode Sep 18, 2026
71e889b
added directory variable for file path
marscancode Sep 19, 2026
f0c63cb
added extension variable for file path
marscancode Sep 20, 2026
a08fe81
explanation of what num represents
marscancode Sep 20, 2026
014e42a
used a comment in javascript
marscancode Sep 20, 2026
4d81b9f
changed const to let for age variable
marscancode Sep 20, 2026
95adf58
explained using a comment and initialised cityOfBirth variable on li…
marscancode Sep 20, 2026
f920359
added prediction of why code on line 1 and 2 wont work
marscancode Sep 20, 2026
7ec6995
explained why my prediction was wrong
marscancode Sep 20, 2026
ed25b1d
fixed typeError by changing cardNumberfrom a number to a string
marscancode Sep 20, 2026
ee9f94c
fixed syntax error by updating both variable names
marscancode Sep 20, 2026
a16ba75
identified all function calls in file in a comment
marscancode Sep 21, 2026
e3fabaf
identified the error and fixed the syntax error on line 5
marscancode Sep 21, 2026
34357e2
Identified variable reassignment statements
marscancode Sep 21, 2026
336102c
identified all variable declarations in file
marscancode Sep 21, 2026
6d81f32
described what the expression on line 4 is doing
marscancode Sep 21, 2026
baf6433
Identified all variable declarations in file
marscancode Sep 21, 2026
efa997d
Identified 1 function call in file
marscancode Sep 21, 2026
eca4da2
explained what the expression on line 3 is doing
marscancode Sep 21, 2026
7cf3da9
explained what the expression assigned to totalMinutes means.
marscancode Sep 21, 2026
92b9bcc
description of result variable and rename suggestion
marscancode Sep 21, 2026
d87544b
answered question f regarding different movieLength values code.
marscancode Sep 21, 2026
fc5d38c
added breakdown of each line in this program
marscancode Sep 21, 2026
91b6ea9
explored using the console in chrome and answered questions
marscancode Sep 21, 2026
ab155d9
explored some additonal console concepts and explained what they do
marscancode Sep 21, 2026
cae3793
completed sprint 2 coursework
marscancode Sep 21, 2026
157f416
fix: reset accidental file changes outside sprint 2
marscancode Sep 21, 2026
2886191
removed line 5
marscancode Sep 21, 2026
2de6944
added clearer description of variable num
marscancode Sep 21, 2026
9a8d497
updated file with error type and explanation
marscancode Sep 21, 2026
7c792ee
updated code on line 18
marscancode Sep 21, 2026
ae092fd
formatted text using prettier
marscancode Sep 21, 2026
538ff7d
updated ext variable to use the lastindexof method and explained why
marscancode Sep 21, 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
1 change: 1 addition & 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,4 @@ 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
//Line 3 is reassigning the variable count to the value of count plus one so the new value would be 1 as count was originally zero so count is now 1.
5 changes: 3 additions & 2 deletions Sprint-2/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ 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 =
firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);

const initials = ``;

console.log(initials);
// https://www.google.com/search?q=get+first+character+of+string+mdn
18 changes: 8 additions & 10 deletions Sprint-2/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@

// (All spaces in the "" line should be ignored. They are purely for formatting.)

const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
const lastSlashIndex = filePath.lastIndexOf("/");
const base = filePath.slice(lastSlashIndex + 1);
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/photo/file.txt";
const lastSlashIndex = filePath.lastIndexOf("/"); //44
const base = filePath.slice(lastSlashIndex + 1); //file.txt
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 = ;

// https://www.google.com/search?q=slice+mdn
const dir = filePath.slice(0, lastSlashIndex);
const ext = filePath.slice(filePath.lastIndexOf("."));
//lastIndexOf() method works better here because it'll look for the last time "." appears in the file path which will always give the correct file ext instead of going a set number back with the slice() method i used previously which may not work for every file extension depending on it length. So now console.log will print .txt or .jpeg if that was the file ext
console.log(ext);
// https://www.google.com/search?q=slice+mdn
9 changes: 9 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,12 @@ 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
//console.log(num)
//output: random whole number

//So num is storing the value of a random number generated by the method Math.random this will be a decimal number between zero and one that is then multiplied by 100 (100(maximum) -1(minimum) +1) and then the Math.floor method will round that number down to the nearest whole number and then finally whatever this number is, one is added on to that number and this final number is what is stored in the variable num. This final number is what is stored in the variable num. The smallest value it can be is 1, and the largest value it can be is 100 as plus minimum means 1 will always be added.

//example Math.random () = 0.97
//0.97 * 100 = 97
//Math.floor = 97
//97+1 = 98
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?
7 changes: 6 additions & 1 deletion Sprint-2/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// trying to create an age variable and then reassign the value by 1

const age = 33;
let age = 33;

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.

The fix is right. The exercise also asks for the error and the reason.

The starter had const age = 33; on this line. Add a comment with the first line of the error node printed. Then say in your own words why it happened.

Tip: the error in 1-key-exercises/4-random.js right now is the same one.

age = age + 1;

console.log(age);

// TypeError: Assignment to constant variable.
//This means javascript cannot reassign const variables. Let must be used in order for the variable to be reassigned so it can change. I have now declared the variable using the let keyword and it now prints (34) in the console.
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 ?

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);

// the variable was initially declared after console.log so it threw an error message. The error message "cannot access 'cityOfBirth' before initialization at Object" is saying that javascript cannot access the variable before it has been initialised. I have initialised the variable on line 3 now so the message prints in the console now.
8 changes: 7 additions & 1 deletion Sprint-2/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cardNumber = 4533787178994213;
const cardNumber = "4533787178994213";
const last4Digits = cardNumber.slice(-4);

// The last4Digits variable should store the last 4 digits of cardNumber
Expand All @@ -7,3 +7,9 @@ const last4Digits = cardNumber.slice(-4);
// 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 predict that it'll throw a syntax error as its not wrapped in "" so it's registering as a number and but it needs to be a string so the .slice() method can register each individual number in last4Digits?
//console.log(last4Digits)
//output: TypeError: cardNumber.slice is not a function
//it's slightly different to what i expected as i thought it was solely about not using the right syntax but it's a type error which after research type error is about not being able to perform a certain operation on a value so here the slice method wouldn't work as .slice() method can only work on strings and arrays so i need to turn cardNumber into a string before the slice() method can work on it. so whilst i was right that it needed "" my reason for why was wrong.
console.log(last4Digits);
12 changes: 10 additions & 2 deletions Sprint-2/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
const 12HourClockTime = "8:53pm";
const 24hourClockTime = "20:53";
const TwelveHourClockTime = "8:53pm";
const TwentyFourHourClockTime = "20:53";
console.log(TwelveHourClockTime);
console.log(TwentyFourHourClockTime);

//output: SyntaxError: Invalid or unexpected token
// Javascript variables cannot start with a number
// Updated numbers in each variable from 12HourClockTime to TwelveHourClockTime
//and 24HourClockTime to TwentyFourHourClockTime and both times now print in
//the console.
9 changes: 6 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 @@ -12,11 +12,14 @@ 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. Line 4(Number and carPrice.replaceAll()), line 5(Number and priceAfterOneYear.replaceAll()) and 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 error message in the terminal tells me there is a syntax error on line 5. There is a comma missing separating the two arguments. I can fix the problem by adding a comma. The console now prints "The percentage change is 14.57".

// c) Identify all the lines that are variable reassignment statements
// There are 2 variable reassignment statements in this file carPrice and priceAfterOneYear as both were first declared on line 1 and 2 using the let keyword before being reassigned on lines 4 and 5.

// d) Identify all the lines that are variable declarations

// the variable declarations are on lines 1 and 2 and lines 7 and 8
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//It is taking the value stored in the variable carPrice and running the method .replaceAll() on the value. so here it is taking 10,000 and removing the comma and then finally this value is turned from a string into a number by being passed into the number function.
8 changes: 6 additions & 2 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,18 @@ 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.

// b) How many function calls are there?
// There is 1 function call the 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 expression uses the remainder operator which returns the remainder left over when one value is divided by another. so here it is asking how many times the number 60 goes into the value stored in the variable movieLength and tell me what is left behind which is what will be stored in the variable remainingSeconds (24).

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?

// The expression here is taking the value stored in remainingSeconds variable and subtracting it from the value stored in movieLength variable, then whatever this value is is divided by 60 and this final number is what gets stored in the variable totalMinutes.
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// The variable result will print a template string showing the movie length as time in hours, time in minutes and time in seconds using a template string. I think movieDuration is a bit more descriptive than result?
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
//The code will work if movieLength is a whole number but it wouldn't work with a decimal number or likely not as expected if it is string unless it contains a number.
16 changes: 13 additions & 3 deletions Sprint-2/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const penceString = "399p";

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

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

const pence = paddedPenceNumberString
Expand All @@ -23,5 +23,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

// 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); initialises a variable that takes the value of variable penceString and uses the method substring() to remove the "p" from "399p" so the variable penceStringWithoutTrailingP now stores the string "399"

//3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); initialises a variable called paddedPenceNumberString that takes the value of variable penceStringWithoutTrailingP and uses the method .padStart() to make sure that the string is always 3 characters long, if it's shorter javascript will pad the value out with a 0 at the start of the value. e.g 39 = 039 or 9 = 009. so paddedPenceNumberString stores "399"

//4.const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2,); initialises a variable that called pounds that takes the value inside paddedPenceNumberString and uses the method subString() on it to remove the last two numbers from the padded string value. So the variable pounds now stores the string "3" which represents £3

//5.const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
//initialises a variable called pence that takes the value of the variable paddedPenceNumberString and runs the .substring() method on it and isolates the last two numbers returning 99. the method .padEnd() then looks at this value and if it's two characters long it wont do anything, if it's less it'll add a 0 to the end of the value. In this case it produced 99 so it doesn't do anything. So the variable pence now stores "99" which represents £.99

//6. console.log(`£${pounds}.${pence}`); This will combine and print the final price using a template literal so the console will print (£3.99)
9 changes: 6 additions & 3 deletions Sprint-2/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ 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 opens a pop up message with the string I passed it (Hello world!)
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`.
const myName = prompt("What is your name?")
console.log(myName)
output: Mars

What effect does calling the `prompt` function have?
What is the return value of `prompt`?
What effect does calling the `prompt` function have? It opens a pop up box asking the user to enter something in a text box here it asked what my name was.
What is the return value of `prompt`? it returns the information entered into the text box as a string so as i entered my name it would return "Mars" and store it in the variable Myname.
10 changes: 8 additions & 2 deletions Sprint-2/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ 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?

ƒ log() { [native code] }
Now enter just `console` in the Console, what output do you get back?

console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}

Try also entering `typeof console`
'object'

Answer the following questions:

What does `console` store?
What does `console` store? it stores tools that i can use to test/ check my code.
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
console.log means open the console and print a certain value or message into the terminal
console.assert allows me. to run quick tests to make sure my program is working and will only alert me if the code is broken.
the "." translates to find this tool.
Loading