From 6e357c7f465a1a288f179163a967468b24f31b3f Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 18:42:49 +0100 Subject: [PATCH 01/25] described code in 1-count.js --- Sprint-1/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..2c97677eb 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -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 +// In line three we assign a new value to the variable "count". +// the = is used to say that this variable should have the value that will be set after the = From 38f900a3ff71c9c22505e1bc91ef9f894fb1fe02 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 18:57:20 +0100 Subject: [PATCH 02/25] Declared a variable that calles the first charachter of each string --- Sprint-1/1-key-exercises/2-initials.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..36ffe3f47 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,11 @@ 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); +initials = initials + middleName.charAt(0); +initials = initials + lastName.charAt(0); + +//console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From b82600e2aa411e0498791374b571f52160fa001d Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 19:37:43 +0100 Subject: [PATCH 03/25] created 2 variables in 3-paths.js , one is to store the fir part of the filepath variable, the other is store the ext part of the variable --- Sprint-1/1-key-exercises/3-paths.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..f705e73e8 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -10,14 +10,19 @@ // (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); + 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); +const ext = filePath.slice(filePath.lastIndexOf(".")); +// to test >> +//console.log(`The dir part of filePath is (( ${dir} )) AND the ext part of it is (( ${ext} ))`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From dcf3d6ffd844dc36b866b3675eda2300646ae30c Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:28:37 +0100 Subject: [PATCH 04/25] Manipulated the code several times to get an idea of how the works and and how to get a random number --- .gitignore | 1 + Sprint-1/1-key-exercises/4-random.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bde36e530..467d53739 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules .DS_Store .vscode +testing.js **/.DS_Store \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..76a75f667 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -1,7 +1,9 @@ -const minimum = 1; -const maximum = 100; +const minimum = 1000; +const maximum = 9999; -const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; +num = Math.floor(Math.random() * (maximum - minimum) + 1); + +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 From 7489fae441f3bf7b92e635d0482bbc83eaf460b4 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:31:13 +0100 Subject: [PATCH 05/25] converted the lines into comments so the program does not run them --- Sprint-1/2-mandatory-errors/0.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..29723340e 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -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? \ 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? + +// we can prevent the pc from running those lines by adding the commenting // lines \ No newline at end of file From 88e4a0d65b069180979bf21a32914972f0b2cedb Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:34:53 +0100 Subject: [PATCH 06/25] Changed the declaration type of the variable from const to let so we can reassign the value --- Sprint-1/2-mandatory-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..031839b47 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -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; From 65ed66ed5daf887a31b4b71db6d238a96ec90f2d Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:39:01 +0100 Subject: [PATCH 07/25] I put the declaration of the variable on the top so the program knows the variable, then print it --- Sprint-1/2-mandatory-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..2865eb8a4 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,5 @@ // 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}`); From b724d4cfda722f471b58499dc4353bc8e0f5cb9c Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:50:45 +0100 Subject: [PATCH 08/25] Coverted the cardnumber from a number to string so it can be sliced --- Sprint-1/2-mandatory-errors/3.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..b2d0c2ab1 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,9 +1,17 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.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 // 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 assume the code won't work because the value inside "slice()" isn't valid. +// because we should set a valid number or 2 numbers (the first num is to set from where to start, +// the second number is to set where to finish) + +// Update: after the first run of the code I realized that CardNumber is actually a number not a string. +// so I think if I convert it into string the code will work properly. No problem with "slice()" value. \ No newline at end of file From 5df6d916ca7efa000126e5101fad1fdb17576f3e Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 20:52:42 +0100 Subject: [PATCH 09/25] Removed numbers from the begining of the variables' names --- Sprint-1/2-mandatory-errors/4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..e8902c0c5 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,2 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const HourClockTime = "20:53"; +const hourClockTime = "08:53"; \ No newline at end of file From ecc906b95da8a1ae9b25f2dd00cfa47f9f12590a Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 21:21:12 +0100 Subject: [PATCH 10/25] code identified, error solved, questions answered --- .../1-percentage-change.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..ea3a2a94c 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/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,29 @@ 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 +// -) functions called are: +// Number() ||| carPrice = Number(carPrice.replaceAll(",", "")); +// Number() ||| priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +// replaceAll() ||| carPrice = Number(carPrice.replaceAll(",", "")); +// replaceAll() ||| priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +// console.log()||| console.log(`The percentage change is ${percentageChange}`); // 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 is coming from line: 5. +// This error is occurring because a , is missing inside the replaceAll() so the two inputs aren't separated. +// I will fix this error by adding , after the first input inside replaceAll() +// replaceAll("," "") Changed to >> +// replaceAll(",", "") // c) Identify all the lines that are variable reassignment statements +// Line 4 +// Line 5 // d) Identify all the lines that are variable declarations +// Line 1 +// Line 2 +// Line 7 +// Line 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// it replaces the , that is inside the number with nothing ( removes the , from the number) From 96f2e356101efd9431e07695e0f91a2f8fb52bae Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 22:16:46 +0100 Subject: [PATCH 11/25] Exercise 3-time-format solved --- .../3-mandatory-interpret/2-time-format.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..f57171a88 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = 86399; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,30 @@ 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 only 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 +// this expression divided the movie length (is seconds) by 60 so we get how many minutes the movie length is. +// but since we used % not / that means we only took the reminder left over after dividing the number. +// so basically the code identifies how many seconds will be left over after getting the minutes amount. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// it means that the result of this expression will be the total minutes of the video. +// before that - in line 3 - it took the number of seconds left, and in line 4 it divides the +// movie length ( takes the remaining seconds out ) by 60 because a minute contains 60 seconds. +// so it actually converts the seconds into minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// The output of the variable result represents time (period of the movie). +// it actually shows the result of converting seconds into readable time format. +// Better to call it (ReadableMovieTime). // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// It does work with most if the values, BUT if I put a number that's bigger than 86399, which returns: 23:59:59 +// that means it ignores the days, it can be mediated so it can count days, months and years. +// I haven't watched a movie that is longer than a day but just in case :), I think the code should be kind of general sometimes!! +// Also two zeros should be displayed if there're not hours or mins (when I put small numbers that are less that an hour), so it gets more understandable. From c1aeb97a76dfaeb621a856d115cf5f647baefe72 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 22 Sep 2025 23:24:57 +0100 Subject: [PATCH 12/25] exercies 3-to-pounds solved --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..dd548bd21 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,10 +1,9 @@ -const penceString = "399p"; +const penceString = "105p"; const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1 ); - const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); const pounds = paddedPenceNumberString.substring( 0, @@ -25,3 +24,22 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. +// 3. const penceStringWithoutTrailingP = penceString.substring( : declares new var and assigns the pence string excluding trailing p +// 4. 0, : first value of the function, this is to tell the function to start from the first charachtar in the string +// 5. penceString.length - 1 : second value of the funtion, it takes the string lengs mines 1 (to exclude trailing p) +// 6. ); : closed th funtion. +// 7. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); : it padds the number with 0 from the start (to make number readable and clear) +// 8. const pounds = paddedPenceNumberString.substring( : declares new variable to store pounds, it takes the last two numbers from the number and stores everything that is before the last two numbers because they are pence not pounds. +// 9. 0, : set 0 to start from the first character. +// 10. paddedPenceNumberString.length - 2 : here is where it excludes the last two numbers (the pence). +// 11. ); : closes function. +// 12. +// 13. const pence = paddedPenceNumberString : declares new var to store pence +// 14. .substring(paddedPenceNumberString.length - 2) : identifies the last two numbers (pence) and stores them. +// 15. .padEnd(2, "0"); : to pad the pence with 0 from the end +// 16. +// 17. console.log(`£${pounds}.${pence}`); : to write the result, it prints the two variables, pounds and pence. it adds £ to show that it's pound. + + + From 5bf072636405140b5795cb6f507a135fee13ac49 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Tue, 23 Sep 2025 02:59:32 +0100 Subject: [PATCH 13/25] Chrome.md done --- Sprint-1/4-stretch-explore/chrome.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..22aa35b30 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -11,8 +11,12 @@ In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; What effect does calling the `alert` function have? +A small box shows up showing the string "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? +a small box in the browser shows up and displays a form to fill. + What is the return value of `prompt`? +the return value of the 'prompt' is the string I enter in that box. \ No newline at end of file From e7f49b1a878c6e878c29bd3e49ea4c8de3c7d43f Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Tue, 23 Sep 2025 03:15:05 +0100 Subject: [PATCH 14/25] objects.md questions answered. --- Sprint-1/4-stretch-explore/objects.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..a8271d4de 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,19 @@ 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? +it shows information that look like variables and values, and starts with something like: +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} Try also entering `typeof console` Answer the following questions: What does `console` store? +Console stores several functions inside it, functions like log(), assert(), debug() and more. + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +`console.log` means that we want to use the function log() that is inside the object (native object) `console`. the dot . means is like navigating from the object to the function inside that object. +so `console.log` means "use the object `console`, then from the functions inside the object use log()". From 27ccab3dc1c8a6dc1b32e5b0efd89fb2a417deb6 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Tue, 23 Sep 2025 03:15:30 +0100 Subject: [PATCH 15/25] Sprint 1 Done! --- Sprint-1/4-stretch-explore/objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index a8271d4de..df4d2527d 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -20,4 +20,4 @@ Console stores several functions inside it, functions like log(), assert(), debu What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? `console.log` means that we want to use the function log() that is inside the object (native object) `console`. the dot . means is like navigating from the object to the function inside that object. -so `console.log` means "use the object `console`, then from the functions inside the object use log()". +so `console.log` means "use the object `console`, then from the functions inside the object use log()". From e86db1ad2c5dacdecf44364acfe90a65eca9c081 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon <138188229+M-Abdoon@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:31:36 +0100 Subject: [PATCH 16/25] Update 4-random.js -- Removed testing line --- Sprint-1/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 76a75f667..bb2e4f1e2 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -3,7 +3,7 @@ const maximum = 9999; num = Math.floor(Math.random() * (maximum - minimum) + 1); -console.log(num); +//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 From 70edf9c4af99ff656d22f3d1b1193c250e7467f8 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon <138188229+M-Abdoon@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:32:34 +0100 Subject: [PATCH 17/25] Update 4-random.js -- returned values to default --- Sprint-1/1-key-exercises/4-random.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index bb2e4f1e2..90df76091 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -1,5 +1,5 @@ -const minimum = 1000; -const maximum = 9999; +const minimum = 1; +const maximum = 100; num = Math.floor(Math.random() * (maximum - minimum) + 1); From 43a32bb6b741b541506b8f0e972c56a0b6c35273 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon <138188229+M-Abdoon@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:33:14 +0100 Subject: [PATCH 18/25] Update 3.js -- Removed testing line --- Sprint-1/2-mandatory-errors/3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index b2d0c2ab1..091394972 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,7 +1,7 @@ const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); -console.log(last4Digits); +//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 @@ -14,4 +14,4 @@ console.log(last4Digits); // the second number is to set where to finish) // Update: after the first run of the code I realized that CardNumber is actually a number not a string. -// so I think if I convert it into string the code will work properly. No problem with "slice()" value. \ No newline at end of file +// so I think if I convert it into string the code will work properly. No problem with "slice()" value. From 13dbe8925b6b06647035de78037a5026a71bd105 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Wed, 24 Sep 2025 13:03:01 +0100 Subject: [PATCH 19/25] Variable declared twice fixed --- Sprint-2/1-key-errors/0.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..f3f399014 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,9 @@ // Predict and explain first... -// =============> write your prediction here +// The code has a function that is supposed to capitalise the string passed to it. (only the first letter) +// the string will be stored in the variable str and the function will return its value. +// it takes the first letter (str[0]) and uses toUpperCase() method to capitalise it. +// the str.slice(1) method is used to show the letter. +// // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -10,4 +14,14 @@ function capitalise(str) { } // =============> write your explanation here +// an error occured because the variable str was already declared as a parameter of the function so +// there was no need to use let again. + + // =============> write your new code here +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} + +console.log(capitalise("hello")); \ No newline at end of file From acaa18f949a67670f23e55da34f44399c08bffa4 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Wed, 24 Sep 2025 14:12:09 +0100 Subject: [PATCH 20/25] ignore unintentionally uploaded file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 467d53739..9115f1062 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules .DS_Store .vscode testing.js +Sprint-2/1-key-errors/0.js **/.DS_Store \ No newline at end of file From 076088c50f4b1c9e23c0efbb2915b03375e9875b Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Wed, 24 Sep 2025 14:13:09 +0100 Subject: [PATCH 21/25] deleted unintentionally uploaded file --- Sprint-2/1-key-errors/0.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Sprint-2/1-key-errors/0.js diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js deleted file mode 100644 index f3f399014..000000000 --- a/Sprint-2/1-key-errors/0.js +++ /dev/null @@ -1,27 +0,0 @@ -// Predict and explain first... -// The code has a function that is supposed to capitalise the string passed to it. (only the first letter) -// the string will be stored in the variable str and the function will return its value. -// it takes the first letter (str[0]) and uses toUpperCase() method to capitalise it. -// the str.slice(1) method is used to show the letter. -// - -// call the function capitalise with a string input -// interpret the error message and figure out why an error is occurring - -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} - -// =============> write your explanation here -// an error occured because the variable str was already declared as a parameter of the function so -// there was no need to use let again. - - -// =============> write your new code here -function capitalise(str) { - str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} - -console.log(capitalise("hello")); \ No newline at end of file From fa3471cbb02843b00ca81822f0c8b78be15b96fa Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon <138188229+M-Abdoon@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:09:42 +0100 Subject: [PATCH 22/25] Update .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9115f1062..caafbee92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ node_modules .DS_Store .vscode testing.js -Sprint-2/1-key-errors/0.js -**/.DS_Store \ No newline at end of file +**/.DS_Store From 667cc7abb4e928faf30c91ea4dac26e8b975c9e0 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon <138188229+M-Abdoon@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:10:07 +0100 Subject: [PATCH 23/25] Update .gitignore From cada88b6438bf6b513131d9ed0751aa3dc90ad48 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 29 Sep 2025 13:47:30 +0100 Subject: [PATCH 24/25] added an explaination of the code and what is actually does. --- Sprint-1/1-key-exercises/4-random.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 90df76091..a150af97c 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -9,3 +9,13 @@ num = Math.floor(Math.random() * (maximum - minimum) + 1); // 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 + +// 1. const minimum = 1; : a variable has the name `minimum` declared. it stores hte 1 value. `const` means this var is unchangeable. +// 2. const maximum = 100; a variable has the name `maximum` declared. it stores hte 100 value. `const` means this var is unchangeable. +// 4. num = Math.floor(Math.random() * (maximum - minimum) + 1); : in this line, the variable `num` is declared, it stores a random number +// between 1 and 100. Math.random() generates a random decimal number between 0 and 1 (exclusive). +// then it multiplies this random number by (maximum - minimum) to scales it to a range between 0 and 99 (since maximum is 100 and minimum is 1). +// Adding 1 shifts this range to be between 1 and 100. +// Math.floor() then rounds down the result number to the nearest whole number, and ensures that num is an integer between 1 and 100. + +// So the whole code generates a random integer between 1 and 100 (inclusive) and stores it in the variable num. \ No newline at end of file From 21231d3480ebac549c2e1db5d5e1142f2f6447f8 Mon Sep 17 00:00:00 2001 From: Mohammed Abdoon Date: Mon, 29 Sep 2025 14:02:35 +0100 Subject: [PATCH 25/25] updated the code explaination --- Sprint-1/1-key-exercises/4-random.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index a150af97c..8def92382 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -16,6 +16,7 @@ num = Math.floor(Math.random() * (maximum - minimum) + 1); // between 1 and 100. Math.random() generates a random decimal number between 0 and 1 (exclusive). // then it multiplies this random number by (maximum - minimum) to scales it to a range between 0 and 99 (since maximum is 100 and minimum is 1). // Adding 1 shifts this range to be between 1 and 100. +// the line had a mistake, it was declared as const num = ... but I changed it to num = ... because const means unchangeable, and here we want to change its value each time we run the code. // Math.floor() then rounds down the result number to the nearest whole number, and ensures that num is an integer between 1 and 100. // So the whole code generates a random integer between 1 and 100 (inclusive) and stores it in the variable num. \ No newline at end of file