Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
330e776
added comment about what line 3 is doing
alexandru-pocovnicu Jun 6, 2025
4766394
updated package-lock.json
alexandru-pocovnicu Jun 6, 2025
a9835a2
declared the variable "initials" that stores the first character of e…
alexandru-pocovnicu Jun 6, 2025
0589f1b
just trying copilot
alexandru-pocovnicu Jun 7, 2025
f0ca65e
created two variables "dir" and"ext"
alexandru-pocovnicu Jun 7, 2025
a035308
logged the value of 'num' and run it several times, added a comment a…
alexandru-pocovnicu Jun 8, 2025
2b670cf
turned the writing in to a multi line comment
alexandru-pocovnicu Jun 8, 2025
1d67096
changed 'age' from a const to a let in order to be able to reassign t…
alexandru-pocovnicu Jun 8, 2025
8cd337f
changed the order of the lines of code
alexandru-pocovnicu Jun 8, 2025
cf91d1e
converted 'cardNumber' to a string
alexandru-pocovnicu Jun 8, 2025
ef6d8f0
changed the names of the variables so they don't start with a number
alexandru-pocovnicu Jun 8, 2025
145c8fd
added a comment
alexandru-pocovnicu Jun 8, 2025
60f84be
fixed the error on line 5 and added comments
alexandru-pocovnicu Jun 8, 2025
5b4927e
added comments with the answers
alexandru-pocovnicu Jun 8, 2025
918e2ec
answered the questions in the comments
alexandru-pocovnicu Jun 8, 2025
247e919
played with the console and answered the questions
alexandru-pocovnicu Jun 8, 2025
5b765e6
wrote answers to the questions
alexandru-pocovnicu Jun 8, 2025
71eb97d
revised the answers for lines 9 and 16
alexandru-pocovnicu Jun 24, 2025
f34420b
changed answer on line 28
alexandru-pocovnicu Jun 24, 2025
cb3fd97
updated the code to work for any file path
alexandru-pocovnicu Jun 24, 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
5 changes: 5 additions & 0 deletions Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ let count = 0;

count = count + 1;

// the "=" assigns value to count which is the sum of count + 1 and which now is "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
// '=' assigns a new value to the variable 'count'
5 changes: 4 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,10 @@ 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);

console.log(initials)

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

//
10 changes: 6 additions & 4 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 = ;

// https://www.google.com/search?q=slice+mdn
const dir = filePath.slice(0,lastSlashIndex);
const dot= base.lastIndexOf(".")
const ext = base.slice(dot)
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
3 changes: 2 additions & 1 deletion Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ 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
// num represents a pseudo-random number and each time it's run it returns a number between 1 and 100
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?*/
// we turn it in to a comment
2 changes: 1 addition & 1 deletion Sprint-1/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;
2 changes: 1 addition & 1 deletion Sprint-1/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Currently trying to print the string "I was born in Bolton" but it isn't working...
// what's the error ?
const cityOfBirth = "Bolton";

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
4 changes: 2 additions & 2 deletions Sprint-1/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);

const last4Digits = cardNumber.toString().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
Expand Down
5 changes: 3 additions & 2 deletions Sprint-1/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
const 12HourClockTime = "20:53";
const 24hourClockTime = "08:53";
const _12HourClockTime = "20:53";
const _24hourClockTime = "08:53";
console.log(_12HourClockTime,_24hourClockTime)
7 changes: 6 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,16 @@ 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
//Answer: 5 function calls on lines 4,5,10

// 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?
//Answer : error on line 5-missing coma, fixed it by adding coma

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

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

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
//Answer: it elimkinates the comma from '10,000' and turns it from a string to a number
8 changes: 7 additions & 1 deletion Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const movieLength = 8784; // length of movie in seconds
const movieLength = 823484; // length of movie in seconds

const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;
Expand All @@ -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?
//Answer: 6 variable declarations

// b) How many function calls are there?
//Answer: 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
//Answer: it represents the seconds remaining after dividing 8784 to 60 which is 24seconds

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
//Answer: it represents the duration of the movie in minutes without the 24 seconds remainder

// e) What do you think the variable result represents? Can you think of a better name for this variable?
//Answer: it represents the movie duration in hh:mm:ss , better name 'movieDuration'

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
//Answer:can't check for all values but it did work for the values I used
20 changes: 18 additions & 2 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ const penceStringWithoutTrailingP = penceString.substring(
0,
penceString.length - 1
);
console.log(penceStringWithoutTrailingP)

const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
console.log(paddedPenceNumberString)

const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
);

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

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

// This program takes a string representing a price in pence
Expand All @@ -25,3 +28,16 @@ console.log(`£${pounds}.${pence}`);

// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
/* 3-6. const penceStringWithoutTrailingP = penceString.substring(
0,
penceString.length - 1
);: creates a string variable called penceStringWithoutTrailingP with the value "399"
9. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");:it creates a string variable has at least three characters
if it doesn't it will add one or more '0'
12-15. const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
);:it creates a string variable with the value of '3'
17-19. it creates a string variable that has the value of the last 2 characters from '399' which is '99'
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script?

Choose a reason for hiding this comment

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

in this script we don't need it , padStart(3,0) takes care of that

21.it logs the values of £ with pounds ,. , and pence combined resulting in £3.99
*/
1 change: 1 addition & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ 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: prompt opens a pop up at the top of the page which contains the question 'what is your name' and the return value of prompt is the name i introduced
9 changes: 5 additions & 4 deletions Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ 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?--- ƒ log() { [native code] }

Now enter just `console` in the Console, what output do you get back?
Now enter just `console` in the Console, what output do you get back?---- console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}

Try also entering `typeof console`
Try also entering `typeof console`----object

Answer the following questions:

What does `console` store?
What does `console` store?----functions
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
The "." is accessing the "log" and "assert" functions inside the console
Loading