Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d543994
explained what line 3 is doing
alexandru-pocovnicu Sep 28, 2025
a7cc13e
extracted initials
alexandru-pocovnicu Sep 28, 2025
cb1e645
assigned values to dir and ext
alexandru-pocovnicu Sep 28, 2025
2d115ce
described what each method does and the order each expression is eval…
alexandru-pocovnicu Sep 28, 2025
f6b6842
added"//" so that the instructions don't get executed
alexandru-pocovnicu Sep 29, 2025
a4b365b
explained why we can't reassign a variable when using "const"
alexandru-pocovnicu Sep 29, 2025
f8be9ec
a variable needs to be declared before being initialized
alexandru-pocovnicu Sep 29, 2025
6631cd9
updated the code by turning the value of cardNumber in to a string
alexandru-pocovnicu Sep 29, 2025
357720b
updated the names of the variables so that they dont't start with num…
alexandru-pocovnicu Sep 29, 2025
f6c81bf
answerred the questions and added a ","
alexandru-pocovnicu Sep 29, 2025
54c1b63
added explanations for variable declarations, function calls, and exp…
alexandru-pocovnicu Sep 29, 2025
62b453f
commented what each line of code does
alexandru-pocovnicu Sep 29, 2025
9264771
add explanations for the effects of the `prompt` function and its ret…
alexandru-pocovnicu Sep 29, 2025
2cb91c3
add explanations for the output of `console` and the syntax of `conso…
alexandru-pocovnicu Sep 29, 2025
6b61b4c
fix: correct the slice start index for the dir part of the filePath
alexandru-pocovnicu Oct 20, 2025
c77d6f3
fix: update comments to clarify the use of const and suggest using le…
alexandru-pocovnicu Oct 20, 2025
fc023eb
fix: reorder variable declaration and console.log to ensure proper ex…
alexandru-pocovnicu Oct 20, 2025
5945501
fix: update comment to clarify the representation of the result variable
alexandru-pocovnicu Oct 20, 2025
f091869
changed movielength, for testing
alexandru-pocovnicu Oct 20, 2025
ab656e8
fix: update movieLength value and rename result variable for clarity
alexandru-pocovnicu Oct 23, 2025
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-1/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
//It assigns the variable"count" a new value of "count+1" which is "1"
9 changes: 8 additions & 1 deletion Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ 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.charAt(0)+middleName.charAt(0)+lastName.charAt(0);

//or

let initials=firstName[0]+middleName[0]+lastName[0]



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

// I really can't understand any of the documentation from developer.mozilla

Choose a reason for hiding this comment

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

What is difficult to understand about the MDN docs?

Choose a reason for hiding this comment

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

I can't really point to one thing which I don't understand, in the end I just copy/paste into chat gpt and ask it to explain

6 changes: 4 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,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 = ;
const dir = filePath.slice(1,lastSlashIndex);

const extPart=base.lastIndexOf(".")
const ext = base.slice(extPart);

// https://www.google.com/search?q=slice+mdn
11 changes: 11 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ const maximum = 100;
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;

// In this exercise, you will need to work out what num represents?
//num represents a variable with the a random number as its value

// Try breaking down the expression and using documentation to explain what it means
//Math.random() returns a pseudo random number that's >=0 and <1
//Math.floor() rounds down to the nearest integer

// It will help to think about the order in which expressions are evaluated
//this first (maximum-minimum+1) then this Math.random()* then this Math.floor() then this +minimum

// Try logging the value of num and running the program several times to build an idea of what the program is doing
//it returns a pseudo random number that's >=0 and <1


console.log(num);
5 changes: 3 additions & 2 deletions Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
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?
// By commenting out the lines
2 changes: 2 additions & 0 deletions Sprint-1/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

const age = 33;
age = age + 1;
//the "age" variable has been declared with a const and already assigned a value and it can not
// be reassigned another value because of the "const"
1 change: 1 addition & 0 deletions Sprint-1/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
//a variable needs to be declared before being initialized
12 changes: 10 additions & 2 deletions Sprint-1/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
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: it won't work because the value of cardNumber is a number and slice() is a string method
const cardNumber = "4533787178994213";
const last4Digits = cardNumber.slice(-4);
console.log(last4Digits);
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 = "20:53";
const 24hourClockTime = "08:53";
// const 12HourClockTime = "20:53";
// const 24hourClockTime = "08:53";

//the name of a variable can not start with a number

const twelveHourClockTime = "20:53";
const twenty4hourClockTime = "08:53";
8 changes: 7 additions & 1 deletion 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,17 @@ 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
// 5 function calls: Number(),replaceAll(),Number(),replaceAll(),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?
//line 5, there was no "," between arguments

// c) Identify all the lines that are variable reassignment statements
//line4,line5

// d) Identify all the lines that are variable declarations
//line1,line2,line7,line8

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//it replaces "," from the carPrice with an empty string, basically deleting the commas, and then turning the string "10000"
// in to a number 10000
6 changes: 6 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,20 @@ 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 variable declarations

// b) How many function calls are there?
//1 function call

// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
//% it's the remainder operator and it tells us how many seconds are left out of a whole minute

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
//total time in minutes without the remaining seconds

// e) What do you think the variable result represents? Can you think of a better name for this variable?
//"Movie length"

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
//it will work with all values as long as they are numbers,

Choose a reason for hiding this comment

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

consider all the edge cases - are there any inputs that might give strange formatting?

Choose a reason for hiding this comment

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

i have tried from 0 to 5464557657, it seems to be working, is there something i'm not seeing?

Choose a reason for hiding this comment

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

The formatting is trying to be HH:MM:SS. Are there any cases where it doesn't give a format exactly like HH:MM:SS?

Because this variable is formatted like HH:MM:SS, if a developer looked at it, would the suggested variable name const totalMovieTime accurately tell me that it's formatted like this?

Choose a reason for hiding this comment

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

i added "0" as padding and changed the name to timeInHhMmSs, but to answer your first question if the hours would be in the 100s then the format would be HHH... etc

27 changes: 23 additions & 4 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const penceString = "399p";
const penceString = "399p";

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

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

const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
Expand All @@ -25,3 +25,22 @@ 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
// ); : it creates a variable with the value "399" by eliminating the character at index penceString.length - 1

//3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");:initialises a string variable of at least 3 characters,
// if it has les than 3 characters it adds 0 to make up for it

//4.const pounds = paddedPenceNumberString.substring(
//0,
// paddedPenceNumberString.length - 2
// );:initialises a string variable with the value of paddedPenceNumberString except the last 2 characters

//5.const pence = paddedPenceNumberString
// .substring(paddedPenceNumberString.length - 2)
// .padEnd(2, "0");: takes the last 2 characters from paddedPenceNumberString , it has to be 2 characters long if not it will add a 0 for
// every missing character
//it adds a dot between pounds and pence and logs 3.99
3 changes: 3 additions & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ What effect does calling the `alert` function have?
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 generates an input field

What is the return value of `prompt`?
whatever is introduced int hte input field
3 changes: 3 additions & 0 deletions Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Try also entering `typeof console`
Answer the following questions:

What does `console` store?
it stores properties

What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
the dot allows to access the properties of the object "console"
Loading