From 8e8fb397284ee83aabec6d9125ad62fed9a7163e Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 12:13:11 +0100 Subject: [PATCH 01/22] add dir and ext --- Sprint-2/1-key-exercises/3-paths.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..96b1bf597 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -13,11 +13,7 @@ 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}`); - -// 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 \ No newline at end of file +const dir = filePath.slice(0,`${lastSlashIndex}`-1); +const ext = filePath.slice(filePath.lastIndexOf(".")); +console.log(`The dir part of ${filePath} is ${dir}`); +console.log(`The ext part of this URL is ${ext}`); \ No newline at end of file From 21470a9300375cf1a6757cd6aef1c120d0954e84 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 12:14:16 +0100 Subject: [PATCH 02/22] explain line 3 --- Sprint-2/1-key-exercises/1-count.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..aa773717f 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -3,4 +3,5 @@ let count = 0; 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 add 1 to value of count and store result back in count, +// in this line = is not mean (is equal to ), It is a assignment From a9e44ee67b3eb8a9dd602accbe266dc52867b8e8 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 12:15:09 +0100 Subject: [PATCH 03/22] find first letter --- Sprint-2/1-key-exercises/2-initials.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 964c9563c..138065c74 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -1,10 +1,6 @@ const firstName = "Creola"; const middleName = "Katherine"; const lastName = "Johnson"; +const initials = `${firstName.charAt(0)}` + `${middleName.charAt(0)}` + `${lastName.charAt(0)}`; +console.log(`${initials}`); -// 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 = ``; - -// https://www.google.com/search?q=get+first+character+of+string+mdn From 59481d1baf7209a126e351be170abc6fd3aa3d3b Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 13:51:30 +0100 Subject: [PATCH 04/22] explain how it working --- Sprint-2/1-key-exercises/4-random.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..dbe4dbbd8 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -2,8 +2,12 @@ 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 random whole number between 1 and 100, +//first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100 +// math.random return number between 0 and 1 +// math.random() * 100 give us a integer number +// math.floor round down the number +// add 1 to the result +//for example math.floor((0.783 *100))=78 + 1 = 79 \ No newline at end of file From fda7c0ded385cbbeac5cfd3912fd60c1eff6e6c0 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 14:00:41 +0100 Subject: [PATCH 05/22] using comment --- Sprint-2/2-mandatory-errors/0.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..ae4599ad6 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,8 @@ -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? \ No newline at end of file +//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 can put "//" in the beginning of the line so computer ignore them +// or put them between /* and */ \ No newline at end of file From a6dbd79fe32858d8844494f8f5f96d0368101c41 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 14:05:03 +0100 Subject: [PATCH 06/22] change const to let --- Sprint-2/2-mandatory-errors/1.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..7f2157819 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,4 +1,6 @@ // 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}`); +//We should use let if we want to change the value. \ No newline at end of file From 5bc72b38502a96c0cc2d2598ce5524c42e0de223 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 14:08:53 +0100 Subject: [PATCH 07/22] change variable position --- Sprint-2/2-mandatory-errors/2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..bc947bb23 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -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}`); +// This error (Cannot access 'cityOfBirth' before initialization) is because we need to declare the variable before using it. + From 516c24cef42b74349499430296259a5dcb08ee6f Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 14:19:21 +0100 Subject: [PATCH 08/22] change var type --- Sprint-2/2-mandatory-errors/3.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..c7c3adfb5 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,9 +1,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 +const last4Digits = String(cardNumber).slice(-4); +console.log(`${last4Digits}`); +// we get error (cardNumber.slice is not a function) because slice is a String method \ No newline at end of file From 01adbcc53e2f1fa15258b873ec5a66baff0e16b7 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 14:24:34 +0100 Subject: [PATCH 09/22] variable name error --- Sprint-2/2-mandatory-errors/4.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..7d033910d 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,3 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const HourClockTime12 = "8:53pm"; +const hourClockTime24 = "20:53"; +//JavaScript variable names cannot start with a number. \ No newline at end of file From a52cfdb73b9f2696b3bfd7f9c5ad0ed4dba928af Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 20:05:52 +0100 Subject: [PATCH 10/22] answer questions --- .../3-mandatory-interpret/1-percentage-change.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..7ea76fa50 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -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; @@ -12,11 +12,24 @@ 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 +/* Number() - line 4 and Line 5 + replaceAll() - Line 4 and Line 5 + console.log() - Line 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? + /* line 5 , There is a comma missing between "," and ""*/ // c) Identify all the lines that are variable reassignment statements + /* Line 4 :carPrice = Number(carPrice.replaceAll(",", "")); + Line5 : priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + carPrice and priceAfterOneYear were already declared on Line 1 and 2 using let */ // d) Identify all the lines that are variable declarations + /* Line 1 : let carPrice = "10,000"; + Line 2 : let priceAfterOneYear = "8,543"; + Line 7 : const priceDifference = carPrice - priceAfterOneYear; + Line 8 : const percentageChange = (priceDifference / carPrice) * 100;*/ // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + /*replaceAll remove all the commas from the string and Number convert string to the number*/ \ No newline at end of file From 71baeb70ff96d8a772a4023c9aa5d9c29ee3301f Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 21:13:44 +0100 Subject: [PATCH 11/22] answer all the question --- Sprint-2/3-mandatory-interpret/2-time-format.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..e73c3c51e 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = 5467; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,25 @@ 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 declaration in this program. + 1- movieLength , 2- remainingSeconds , 3- totalMinutes + 4- remainingMinutes , 5- totalHours , 6- result */ // b) How many function calls are there? +/* one function + Line 10 : 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 +// Remainder(%) : Return the remainder left over when one operand is divided by a second operand +// console.log(13 % 5 ); 3 // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// This expression converts movie length from seconds into minutes // e) What do you think the variable result represents? Can you think of a better name for this variable? +// Variable result represent the movie length formatted as hours, minutes, seconds , +// another name could be movieTime // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// This code works for normal positive number representing but for negative number and very big number it is not working \ No newline at end of file From 4e607b24aab6c98b6a2fc371b2badd301ad7133c Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Thu, 17 Sep 2026 23:43:32 +0100 Subject: [PATCH 12/22] understand and answer question --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..7445a4689 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,19 @@ 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); +// create a new variable and put the string without p + +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +// padStart() adds characters to the beginning of a string to make it 3 characters long. +// because we need to convert it to pound and pence + +// 4. const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); +// We remove the last 2 characters and store the remaining part of the string as pounds. + +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + // Gets the last two characters as pence.” + + // 6. console.log(`£${pounds}.${pence}`); + //. Finally combine pound and pence \ No newline at end of file From 837636d177ff21bd57ab1e571e24a4c7c5f13da3 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sat, 19 Sep 2026 21:05:40 +0100 Subject: [PATCH 13/22] learn about console and objects --- Sprint-2/4-stretch-explore/objects.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..a49d61a90 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -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 the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +console stores object. It stores a collection of methods that allow you to interact with the browser's developer console. +what does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +access the log property/method of the console object. +access the assert method of the console object. \ No newline at end of file From 373e8ae3b2a0c5a08e181e0802896e5858fc00d3 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sat, 19 Sep 2026 21:10:50 +0100 Subject: [PATCH 14/22] Complete sprint 2 coursework --- Sprint-2/4-stretch-explore/chrome.md | 5 ++++- prep/errortest.js | 1 + prep/facts.js | 1 + prep/greeting.js | 6 ++++++ prep/hello_world.js | 1 + prep/passwordChecker.js | 14 ++++++++++++++ prep/sprint-2/notes.md | 13 +++++++++++++ 7 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 prep/errortest.js create mode 100644 prep/facts.js create mode 100644 prep/greeting.js create mode 100644 prep/hello_world.js create mode 100644 prep/passwordChecker.js create mode 100644 prep/sprint-2/notes.md diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..043cccd72 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -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? +alert(): shows the message to the users. in this case show "Hello world!" in the box and we can close it or click on the ok. 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 effect does calling the `prompt` function have? +prompt(): returns whatever the user enters. It is provide a textbox that we can type on it. What is the return value of `prompt`? +The Return value of prompt is the text enter by user. in this example return name that we write in the box. diff --git a/prep/errortest.js b/prep/errortest.js new file mode 100644 index 000000000..0334b677d --- /dev/null +++ b/prep/errortest.js @@ -0,0 +1 @@ +console.log (math.round(10.3); \ No newline at end of file diff --git a/prep/facts.js b/prep/facts.js new file mode 100644 index 000000000..9a6bcf5de --- /dev/null +++ b/prep/facts.js @@ -0,0 +1 @@ +console.log("It take two days to find how to choose Need reviews in PR just because a simple mistake."); \ No newline at end of file diff --git a/prep/greeting.js b/prep/greeting.js new file mode 100644 index 000000000..a84bad1ae --- /dev/null +++ b/prep/greeting.js @@ -0,0 +1,6 @@ +console.log("hello" === "hello"); +console.log("CYF" === "cyf"); +const homeTown = "Newcastle" +console.log(homeTown === "liverpool"); +console.log(42 === 42); +console.log(42 !== "42") \ No newline at end of file diff --git a/prep/hello_world.js b/prep/hello_world.js new file mode 100644 index 000000000..940a3ff0e --- /dev/null +++ b/prep/hello_world.js @@ -0,0 +1 @@ +console.log("Hello world!"); diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js new file mode 100644 index 000000000..e961c9dc9 --- /dev/null +++ b/prep/passwordChecker.js @@ -0,0 +1,14 @@ +const password = "secretword123"; +const userInput = "thisiswrong"; +const adminPassword = "override"; +let response = ""; + +if (userInput === password){ + response = "Correct password entered"; +} else if (userInput === adminPassword){ + response = "Admin access granted"; +} else { + response = "Incorrect password!"; +} + +console.log(response); diff --git a/prep/sprint-2/notes.md b/prep/sprint-2/notes.md new file mode 100644 index 000000000..c0ef06f89 --- /dev/null +++ b/prep/sprint-2/notes.md @@ -0,0 +1,13 @@ +# Sprint 2 Notes + +## Things I have learned + +* + +## Commands I have used + +* + +## JavaScript + +* From cfee6b6b199391a4cff54c301b22674fbe38c9a9 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 10:25:17 +0100 Subject: [PATCH 15/22] Remove unrelated prep files --- prep/errortest.js | 1 - prep/facts.js | 1 - prep/greeting.js | 6 ------ prep/hello_world.js | 1 - prep/passwordChecker.js | 14 -------------- 5 files changed, 23 deletions(-) delete mode 100644 prep/errortest.js delete mode 100644 prep/facts.js delete mode 100644 prep/greeting.js delete mode 100644 prep/hello_world.js delete mode 100644 prep/passwordChecker.js diff --git a/prep/errortest.js b/prep/errortest.js deleted file mode 100644 index 0334b677d..000000000 --- a/prep/errortest.js +++ /dev/null @@ -1 +0,0 @@ -console.log (math.round(10.3); \ No newline at end of file diff --git a/prep/facts.js b/prep/facts.js deleted file mode 100644 index 9a6bcf5de..000000000 --- a/prep/facts.js +++ /dev/null @@ -1 +0,0 @@ -console.log("It take two days to find how to choose Need reviews in PR just because a simple mistake."); \ No newline at end of file diff --git a/prep/greeting.js b/prep/greeting.js deleted file mode 100644 index a84bad1ae..000000000 --- a/prep/greeting.js +++ /dev/null @@ -1,6 +0,0 @@ -console.log("hello" === "hello"); -console.log("CYF" === "cyf"); -const homeTown = "Newcastle" -console.log(homeTown === "liverpool"); -console.log(42 === 42); -console.log(42 !== "42") \ No newline at end of file diff --git a/prep/hello_world.js b/prep/hello_world.js deleted file mode 100644 index 940a3ff0e..000000000 --- a/prep/hello_world.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello world!"); diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js deleted file mode 100644 index e961c9dc9..000000000 --- a/prep/passwordChecker.js +++ /dev/null @@ -1,14 +0,0 @@ -const password = "secretword123"; -const userInput = "thisiswrong"; -const adminPassword = "override"; -let response = ""; - -if (userInput === password){ - response = "Correct password entered"; -} else if (userInput === adminPassword){ - response = "Admin access granted"; -} else { - response = "Incorrect password!"; -} - -console.log(response); From ccb29be8e535e4d053c9b71d17f9d5f85a8dc68e Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 10:30:42 +0100 Subject: [PATCH 16/22] Remove prep files --- prep/sprint-2/notes.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 prep/sprint-2/notes.md diff --git a/prep/sprint-2/notes.md b/prep/sprint-2/notes.md deleted file mode 100644 index c0ef06f89..000000000 --- a/prep/sprint-2/notes.md +++ /dev/null @@ -1,13 +0,0 @@ -# Sprint 2 Notes - -## Things I have learned - -* - -## Commands I have used - -* - -## JavaScript - -* From 73b8e2648604a93801c9169cbcc1daee7c9f7ae0 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 17:59:52 +0100 Subject: [PATCH 17/22] fix the error --- Sprint-2/2-mandatory-errors/0.js | 2 +- Sprint-2/2-mandatory-errors/1.js | 3 ++- Sprint-2/2-mandatory-errors/2.js | 1 - Sprint-2/2-mandatory-errors/3.js | 2 +- Sprint-2/2-mandatory-errors/4.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index ae4599ad6..ccf28a0fe 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -5,4 +5,4 @@ We don't want the computer to run these 2 lines - how can we solve this problem???*/ // we can put "//" in the beginning of the line so computer ignore them -// or put them between /* and */ \ No newline at end of file +// or put them between /* and */ diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7f2157819..26ce53c60 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -3,4 +3,5 @@ let age = 33; age = age + 1; console.log(`${age}`); -//We should use let if we want to change the value. \ No newline at end of file +//We should use let if we want to change the value. +//Before I changed const to let node show this error message: (Assignment to constant variable.) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index bc947bb23..c728ae6fe 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -3,4 +3,3 @@ const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); // This error (Cannot access 'cityOfBirth' before initialization) is because we need to declare the variable before using it. - diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index c7c3adfb5..f4482226c 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ const cardNumber = 4533787178994213; const last4Digits = String(cardNumber).slice(-4); console.log(`${last4Digits}`); -// we get error (cardNumber.slice is not a function) because slice is a String method \ No newline at end of file +// we get error (cardNumber.slice is not a function) because slice is a String method diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 7d033910d..56d5f93bc 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,3 +1,3 @@ const HourClockTime12 = "8:53pm"; const hourClockTime24 = "20:53"; -//JavaScript variable names cannot start with a number. \ No newline at end of file +//JavaScript variable names cannot start with a number. From 7d4131006e3ded53b2a37c76cd4b88e65a7676c5 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 19:00:52 +0100 Subject: [PATCH 18/22] correct the wrong answer --- Sprint-2/1-key-exercises/3-paths.js | 4 ++-- Sprint-2/1-key-exercises/4-random.js | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 96b1bf597..26178dcae 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -13,7 +13,7 @@ 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}`); -const dir = filePath.slice(0,`${lastSlashIndex}`-1); +const dir = filePath.slice(0, `${lastSlashIndex}`); const ext = filePath.slice(filePath.lastIndexOf(".")); console.log(`The dir part of ${filePath} is ${dir}`); -console.log(`The ext part of this URL is ${ext}`); \ No newline at end of file +console.log(`The ext part of this URL is ${ext}`); diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index dbe4dbbd8..fb4f79bbc 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -1,13 +1,12 @@ const minimum = 1; const maximum = 100; - const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; console.log(`${num}`); //num represents a random whole number between 1 and 100, -//first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100 +//first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100 // math.random return number between 0 and 1 -// math.random() * 100 give us a integer number +// math.random() * 100 give us a decimal number // math.floor round down the number -// add 1 to the result -//for example math.floor((0.783 *100))=78 + 1 = 79 \ No newline at end of file +// add 1 to the result +//for example math.floor((0.783 *100))=78 + 1 = 79 From e7652365c9298a0511f92481dd0125778b7280cd Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 19:16:06 +0100 Subject: [PATCH 19/22] changes answer --- Sprint-2/3-mandatory-interpret/2-time-format.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index e73c3c51e..8ad9a113a 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 5467; // length of movie in seconds +const movieLength = -98; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -26,11 +26,11 @@ console.log(result); // console.log(13 % 5 ); 3 // d) Interpret line 4, what does the expression assigned to totalMinutes mean? -// This expression converts movie length from seconds into minutes +// This expression converts movie length from seconds into minutes // e) What do you think the variable result represents? Can you think of a better name for this variable? -// Variable result represent the movie length formatted as hours, minutes, seconds , +// Variable result represent the movie length formatted as hours, minutes, seconds , // another name could be movieTime // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer -// This code works for normal positive number representing but for negative number and very big number it is not working \ No newline at end of file +//So the code works properly for whole numbers, but not for negative numbers and decimal numbers because the result can contain decimal values. From 8c04eec5488241db3f4ba31dc90770cdab90ce4c Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 19:19:44 +0100 Subject: [PATCH 20/22] format documets --- .../3-mandatory-interpret/1-percentage-change.js | 9 ++++----- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 16 ++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 7ea76fa50..e1f7ae341 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -16,20 +16,19 @@ console.log(`The percentage change is ${percentageChange}`); replaceAll() - Line 4 and Line 5 console.log() - Line 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? - /* line 5 , There is a comma missing between "," and ""*/ +/* line 5 , There is a comma missing between "," and ""*/ // c) Identify all the lines that are variable reassignment statements - /* Line 4 :carPrice = Number(carPrice.replaceAll(",", "")); +/* Line 4 :carPrice = Number(carPrice.replaceAll(",", "")); Line5 : priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); carPrice and priceAfterOneYear were already declared on Line 1 and 2 using let */ // d) Identify all the lines that are variable declarations - /* Line 1 : let carPrice = "10,000"; +/* Line 1 : let carPrice = "10,000"; Line 2 : let priceAfterOneYear = "8,543"; Line 7 : const priceDifference = carPrice - priceAfterOneYear; Line 8 : const percentageChange = (priceDifference / carPrice) * 100;*/ // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? - /*replaceAll remove all the commas from the string and Number convert string to the number*/ \ No newline at end of file +/*replaceAll remove all the commas from the string and Number convert string to the number*/ diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 7445a4689..9c814cf4f 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -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 @@ -27,17 +27,17 @@ console.log(`£${pounds}.${pence}`); // 1. const penceString = "399p": initialises a string variable with the value "399p" // 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); -// create a new variable and put the string without p +// create a new variable and put the string without p // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); -// padStart() adds characters to the beginning of a string to make it 3 characters long. -// because we need to convert it to pound and pence +// padStart() adds characters to the beginning of a string to make it 3 characters long. +// because we need to convert it to pound and pence // 4. const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); // We remove the last 2 characters and store the remaining part of the string as pounds. // 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); - // Gets the last two characters as pence.” +// Gets the last two characters as pence.” - // 6. console.log(`£${pounds}.${pence}`); - //. Finally combine pound and pence \ No newline at end of file +// 6. console.log(`£${pounds}.${pence}`); +//. Finally combine pound and pence From 9663fde5686f4154620e77733833a85f361556ae Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 20:16:34 +0100 Subject: [PATCH 21/22] Configure format on save and fix formatting --- Sprint-2/1-key-exercises/2-initials.js | 6 ++++-- Sprint-2/4-stretch-explore/chrome.md | 2 +- Sprint-2/4-stretch-explore/objects.md | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 138065c74..9c4e8312e 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -1,6 +1,8 @@ const firstName = "Creola"; const middleName = "Katherine"; const lastName = "Johnson"; -const initials = `${firstName.charAt(0)}` + `${middleName.charAt(0)}` + `${lastName.charAt(0)}`; +const initials = + `${firstName.charAt(0)}` + + `${middleName.charAt(0)}` + + `${lastName.charAt(0)}`; console.log(`${initials}`); - diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 043cccd72..fa95e5b37 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -12,7 +12,7 @@ alert(): shows the message to the users. in this case show "Hello world!" in the 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 effect does calling the `prompt` function have? prompt(): returns whatever the user enters. It is provide a textbox that we can type on it. What is the return value of `prompt`? The Return value of prompt is the text enter by user. in this example return name that we write in the box. diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index a49d61a90..91c0660c9 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -19,4 +19,4 @@ What does `console` store? console stores object. It stores a collection of methods that allow you to interact with the browser's developer console. what does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? access the log property/method of the console object. -access the assert method of the console object. \ No newline at end of file +access the assert method of the console object. From 7fa22d67be72e0f56b0b76e27bdc3214be7bc2a2 Mon Sep 17 00:00:00 2001 From: shirinpanahian Date: Sun, 20 Sep 2026 20:22:03 +0100 Subject: [PATCH 22/22] remove unnecessary backticks --- Sprint-2/1-key-exercises/3-paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 26178dcae..669b88cff 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -13,7 +13,7 @@ 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}`); -const dir = filePath.slice(0, `${lastSlashIndex}`); +const dir = filePath.slice(0, lastSlashIndex); const ext = filePath.slice(filePath.lastIndexOf(".")); console.log(`The dir part of ${filePath} is ${dir}`); console.log(`The ext part of this URL is ${ext}`);