Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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-1/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

// Line 3 increases the number by one and reassigns the new value to count, which stored 0 .

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.

Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.

Can you find out what one-word programming term describes the operation on line 3?

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 @@ -7,5 +7,8 @@ let lastName = "Johnson";

let initials = ``;

// https://www.google.com/search?q=get+first+character+of+string+mdn
let initials = `${firstName.charAt(0)} ${middleName.charAt(0)} ${lastName.charAt(0)}`;

console.log(initials);
Comment on lines +10 to +12

@cjyuan cjyuan Jun 23, 2026

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.

Currently, the value assigned to initials does not fully match the expected string, "CKJ", a string of three characters.


// https://www.google.com/search?q=get+first+character+of+string+mdn
11 changes: 7 additions & 4 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
const lastSlashIndex = filePath.lastIndexOf("/");
const base = filePath.slice(lastSlashIndex + 1);
console.log(`The base part of ${filePath} is ${base}`);
// 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 + 1);

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.

Do you intend to including a trailing / in the string assigned to dir?

const ext = filePath.slice(filePath.lastIndexOf("."));

// https://www.google.com/search?q=slice+mdn
// console.log(ext);

// https://www.google.com/search?q=slice+mdn
// console.log(dir);
8 changes: 8 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ 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);

// 1) Num represent a randomly generated whole number between maximum and minimum //

// 2) Firstly, Math.random create a random number between 0 to 1 then using a maximum and minimum,which gives us range.
// Multiplying them create a random number inside that range. Math.floor remove decimal parts and give us whole number
// finally we add minimum number ( + minimum),which start from a minimum value. Therefore num represent a whole number.
Comment on lines +13 to +17

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.

Phrases like "a number between X and Y" are not precise enough in a program specification, because they do not clearly state whether the endpoints X and Y are included.

Could you describe the range of the numbers each of the following expressions may produce?

  1. Math.random()
  2. Math.random() * (maximum - minimum + 1)
  3. Math.floor(Math.random() * (maximum - minimum + 1))
  4. Math.floor(Math.random() * (maximum - minimum + 1)) + minimum

Note: One way to describe a range of numbers is to use the math's interval notation:

  • [, ] => inclusion
  • (, ) => exclusion

For example, [1, 10) means, all numbers between 1 and 10, including 1 but excluding 10.

4 changes: 3 additions & 1 deletion Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
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 don't want the computer to run these 2 lines - how can we solve this problem?

// We comment them using slash(//) where human can read and computer can't read because it is not a code or translated into code//
3 changes: 2 additions & 1 deletion Sprint-1/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);
3 changes: 2 additions & 1 deletion Sprint-1/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}`);
6 changes: 4 additions & 2 deletions Sprint-1/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);
let cardNumber = 4533787178994213;
const ToString = cardNumber.toString();

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.

In JS naming convention, variable names usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g., Math)

let last4Digits = ToString.slice(-4);
console.log(last4Digits);

// The last4Digits variable should store the last 4 digits of cardNumber
// However, the code isn't working
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 = "8:53pm";
const 24hourClockTime = "20:53";
const HourClockTime = "8:53pm";
const hourClockTime = "20:53";
Comment on lines +1 to +2

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.

Could you also rename these to match JS naming convention?

// console.log(HourClockTime);
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 @@ -20,3 +20,9 @@ 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?

// 1) five function call there including log function .Lines 4 has two function and lines 5 has two function .
// 2 ) problem was line number 5 where comma was missing.

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.

We can more precisely describe "A comma is missing between "," and "" in the function call" as:
A comma is missing between the ___________s.

What is the programming term that belongs in the blank?

// 3) reassignment statement lines are 4 and 5.
// 4) declaration lines are 1,2,7 and 8
// 5) line number 4, first it is removing commas using replaceAll then converting string to number for calculation.
9 changes: 8 additions & 1 deletion Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const movieLength = 8784; // length of movie in seconds

// 9237, 8784, -5897...
const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;

Expand All @@ -23,3 +23,10 @@ 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

// a) there are 6 variable declaration.
// b) there is zero function call . (only one is console.log but it is not part code execution)
// c)represents the number of seconds left over after converting the movie length into whole minutes.
// d) It calculates how many whole minutes are in the movie after taking away extra second that don't make full minutes.
// e) it represents time format like hours : minutes: second and I think MovieLengthDuration or short MovieDuration

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.

Could consider including a "formatted" prefix in the name to suggest it stores a string.

// I think all value will work except negative value because negative value gives negative outcome.
7 changes: 7 additions & 0 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ console.log(`£${pounds}.${pence}`);

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

// line 1 creating a string containing price in pence and this is starting value that programme will convert into pound.
// line 3 removing p from the end of 399p because p is not needed when converting into pound or pence.
// line 8 making sure string has at least 3 digit by adding zero if needed and this makes easier to separate pound and pence consistently.
// line 9 extract everything except last two digit .
// line 14 extract last two digit and padEnd() ensures the pence part always has 2 digits.
// line 18 to print value for checking .
4 changes: 4 additions & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ invoke the function `alert` with an input string of `"Hello world!"`;

What effect does calling the `alert` function have?

1. alert function display a pop-up message box in the browser containing text "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`.

What effect does calling the `prompt` function have?
What is the return value of `prompt`?

2. calling a prompt display a pop-up message box and ask for user input and prompt return a text entered by user as string.
Comment on lines 20 to +22

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.

What does prompt() return when the user entered a name and then click "Cancel" (instead of "OK")?

7 changes: 7 additions & 0 deletions Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ Open the Chrome devtools Console, type in `console.log` and then hit enter

What output do you get?

answer: it shows only log function itself.

Now enter just `console` in the Console, what output do you get back?
answer: the output is console object .it shows available function/ method inside console object.

Try also entering `typeof console`
Answer: this shows that console is object.

Answer the following questions:

What does `console` store?
answer: this one store an object that contain method used to interact with browser developer console.

What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
Answer : this one let us access to log function that store console object. `.` this one is a dot operator used to access something inside object . console.assert means accessing the assert method from the console object.
Loading