From 209ea8ffbe13c26c7d195e9a57e78d4e4eceea19 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 29 May 2025 18:38:08 +0100 Subject: [PATCH 01/29] explained line 3 - variable reassignment --- Sprint-1/1-key-exercises/1-count.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..e0eba84ff 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,9 @@ 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 + +/* + Answer: in line 3, the variable count gets reassigned a new value which is the sum of the old value and 1. +In other words, the variable count is now adding 1 to its old value to obtain a new value. +*/ + From cf11f38f704a108b14a630e15fa7daad1b822f40 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 29 May 2025 18:57:49 +0100 Subject: [PATCH 02/29] declared variable stores initial of each word --- Sprint-1/1-key-exercises/2-initials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..3e9e5b37c 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,7 @@ 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)}`; // https://www.google.com/search?q=get+first+character+of+string+mdn From 9751116ce4b8aea25041d60a553f330951bc9d74 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 09:09:19 +0100 Subject: [PATCH 03/29] created 2 variables to store different filepathes --- Sprint-1/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 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..be2403a81 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,7 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable -const dir = ; -const ext = ; +const dir = filePath.slice(1,lastSlashIndex); +const ext = filePath.slice(filePath.indexOf(".")); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From c263fad44819427ecc96a9f73d67587cc71f4e30 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 09:56:38 +0100 Subject: [PATCH 04/29] Completed Math object * its methods exercises --- Sprint-1/1-key-exercises/4-random.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..596f88479 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,15 @@ 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 + +/* +1. num represents any random whole number (integer) between 1 and 100 (both included) +2. Math.floor(x) it rounds down x to a value that is less than or equal to x, while Math.random() it generates random + numbers that are equal to 0 and less than 1. +3. before we multiply (Math.random() by (maximum - minimum + 1) or vice versa, each expression gets evaulated + first on its own. Math.random() leads to an integer between 0 and less 1, while (maximum - minimum + 1)) evaluates + to 100. Then multiplication comes into place and we get floats from 0.00 and less than 100. Having Math.floor() + as a method basically means we now have random integers from 0 and 99. By considering the last part of the value + assigned to num, we now have random integers from 1 and 100 (both included). +4. Done! +*/ From 8ab5a4ef6cfff054ca77a6f4cbbe86ec32e12d02 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 10:00:07 +0100 Subject: [PATCH 05/29] Commented to avoid running my lines of code --- Sprint-1/2-mandatory-errors/0.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..439b78c26 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,5 @@ 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 +We don't want the computer to run these 2 lines - how can we solve this problem? + +// we can simply comment the 2 lines, just like what I am doing here! +// single line comments use "//" multi-line comments use/* */ \ No newline at end of file From e8108f8038a9e7df71f1576ec34e24930b17851a Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 16:31:19 +0100 Subject: [PATCH 06/29] SyntaxError solved by commenting --- Sprint-1/2-mandatory-errors/0.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index 439b78c26..338322031 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,5 +1,17 @@ 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? + +/* +I got "SyntaxError: Unexpected identifier" error message. It happen because the 2 lines don't make sense. +the computor sees the first word and it assumes a variable or a function is being declared but then when +it reads the resut of the sentence it breaks as this is not how an identifier is being used and formed in +a programme. +To avoid this issue, we can just simply comment the 2 lines, just like what I am doing here! + +*/ + +/* +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 simply comment the 2 lines, just like what I am doing here! -// single line comments use "//" multi-line comments use/* */ \ No newline at end of file From 5c1b48b34f2030b03fcc53af7266ea1a3f79f46d Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 16:44:01 +0100 Subject: [PATCH 07/29] declaration keyword changed to let to solve error --- Sprint-1/2-mandatory-errors/1.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..e3f3fa385 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,15 @@ const age = 33; age = age + 1; + +/* +I got this error message "TypeError: Assignment to constant variable." after running +my code. It happened because when assigned a value to an identifer using const -short +for constant - it emplies that we have no intention of changing the value. it remains +constant. the second line the variable get reassigned a new value and therefore the +error message above showed up. +To solve this issue the variable age could simply be declared via "let" as seen below: +*/ + +let age = 33; +age = age + 1; \ No newline at end of file From 2a36aae69b000e47000d2fbd439df52a57139350 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 16:52:08 +0100 Subject: [PATCH 08/29] ReferenceError avoided by declaring variable first --- Sprint-1/2-mandatory-errors/2.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..71f5a90c4 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,15 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +/* +The error message "ReferenceError: Cannot access 'cityOfBirth' before initialization + at Object. " comes up because when the computor reads the first line it + recognised that cityOfbirth is an identifer however it get confused as it has not + been declaed beforehand and runs into an error as a result. To overcome this issue + and access cityOfBirth, simply declare it in the 1st line and then in the 2nd line + use console.log() to display its value to the terminal as seen below: +*/ + +const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); \ No newline at end of file From 064ecb3b520089e8b8be188223b905efc2d74ce2 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 22:15:24 +0100 Subject: [PATCH 09/29] last4Digits value updated to avoid error message. --- Sprint-1/2-mandatory-errors/3.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..f5c695eeb 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,5 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +//const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +7,12 @@ const last4Digits = cardNumber.slice(-4); // 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 + + +/* +This error message was thrown after running the code "TypeError: cardNumber.slice is not a function". +It simply happned because ".slice()" is not a method associated with integers but strings & arrays. +To avoid this issue the value of last4Digits should be as below: +*/ + +const last4Digits = cardNumber.toString().slice(-4); From 547fbebac8b165faeefe6660923c18411e913b25 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 30 May 2025 22:30:49 +0100 Subject: [PATCH 10/29] renamed variables to avoid syntax error --- Sprint-1/2-mandatory-errors/4.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..63290784a 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,7 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +//const 12HourClockTime = "20:53"; +//const 24hourClockTime = "08:53"; + +// to avoid the syntax error after running the above lines of code do as below: + +const ClockTime12Hour = "20:53"; +const ClockTime24hour = "08:53"; \ No newline at end of file From 608f18dbd7ec65ddc3dd3a272a0418d517a413d2 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 2 Jun 2025 09:43:36 +0100 Subject: [PATCH 11/29] added comma between inputs (line 5) to solve error --- .../1-percentage-change.js | 17 ++++++++++++++++- 1 file changed, 16 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..d38db4604 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; @@ -20,3 +20,18 @@ 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? + +/* +a) There are 5 at: 1)carPrice = Number(carPrice.replaceAll(",", "")); & 2)priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")), +3) & 4) const priceDifference = carPrice - priceAfterOneYear; 5) const percentageChange = (priceDifference / carPrice) * 100; + +b) The error happened due to the missing comma "," in between the 2 parameters/arguments in line 5's function call. Just add a comma to solve +this problem. + +c) line 4 & line 5 + +d) line 1 & line 2 + +e) The last expression gets rid of all the commas present in the declared variables in line 1 & 2. or in other words, replaces them commas with +no space between the characters separated by the commas. +*/ From 47d435ef92ea7cdfa4c87239f7dd10d431f32686 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 2 Jun 2025 10:13:11 +0100 Subject: [PATCH 12/29] completed time format --- Sprint-1/3-mandatory-interpret/2-time-format.js | 13 ++++++++++++- 1 file changed, 12 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..16e208973 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 = -10; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -23,3 +23,14 @@ 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 in total. +b) 0 function calls. +c) it represents the remainder from the division of movieLength by 60. +d) line 4 represents the total number of mins in the movie (as whole numbers -integers) by getting rid of the decimal parts (in secs). +e) Result represents the total movie duration (in exact hours, exact min and exact sec). movieDuration could be a good name. +f) it works. However, if there's enough time to form a whole hour(s) for example the results shows the total mins and total secs and so +on. So I'd say it works. +*/ From 408a4f23be9dcefcc30b2074174036d56a7a1d2d Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 2 Jun 2025 19:44:11 +0100 Subject: [PATCH 13/29] explanation for the code provided --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..cd8cd5f54 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,9 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. ine lines 3-6, penceStringWithoutTrailingP is being declared to get rid of the "p" part of "399p" so that you end up with "399" ONLY. +// 3. Lines 8 paddedPenceNumberString adds "0" to the start of paddedPenceNumberString which is "399" with the aim of it have a total length of 3. +// 4. Lines 9-12, pound is being declared, the value of it aims to extract the "full pounds part" considering 1 pound = 1-- pence. +// 4. Lines 14-16, extract the "pence part" fraction +// 5. Line 18 prints out the sum in pounds and pense. + From e57e5905af99e0c0006c76de06e9760855b3d4d6 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 2 Jun 2025 20:06:19 +0100 Subject: [PATCH 14/29] V8 questions answered --- 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..dfa9c1976 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 message with Hello world! message pops up in a small Chrome notification window 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`. +// small Chrome window pops up with "What is your name?" and underneath it a space for the user to enter and submit their name. What effect does calling the `prompt` function have? +//prompt expect input from the user by showing a small window with space for input to be submitted once called. What is the return value of `prompt`? +//undefined From d1e40e476597db4a75d321c975ff71bf035d7abe Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 2 Jun 2025 20:27:10 +0100 Subject: [PATCH 15/29] answered all questions --- Sprint-1/4-stretch-explore/objects.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..725d60897 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -4,13 +4,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? +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` +// got 'object' as an output Answer the following questions: What does `console` store? +//console doesn't store. it displays. What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +//console.log log or display values to the console. Console.assert, check if a condition is true and in this case no output. Otherwise, an +// error message shows. As for the `,`, it's called the dot notation and it's used to access properties and methods of an object. From b0469be729068270db37c1dcf1e7d1ae272873f6 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:11:20 +0100 Subject: [PATCH 16/29] updated = described line 3 --- Sprint-1/1-key-exercises/1-count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index e0eba84ff..64c9abe21 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -6,7 +6,7 @@ count = count + 1; // Describe what line 3 is doing, in particular focus on what = is doing /* - Answer: in line 3, the variable count gets reassigned a new value which is the sum of the old value and 1. + Answer: line 3 shows increment operation - the variable count gets reassigned a new value which is the sum of the old value and 1. In other words, the variable count is now adding 1 to its old value to obtain a new value. */ From a6e7a480db3265f3437c8e43eab2cae905f09d13 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:36:29 +0100 Subject: [PATCH 17/29] simplified description - used technical terms --- Sprint-1/1-key-exercises/4-random.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 596f88479..0f4feb14d 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -9,13 +9,9 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try logging the value of num and running the program several times to build an idea of what the program is doing /* -1. num represents any random whole number (integer) between 1 and 100 (both included) -2. Math.floor(x) it rounds down x to a value that is less than or equal to x, while Math.random() it generates random - numbers that are equal to 0 and less than 1. -3. before we multiply (Math.random() by (maximum - minimum + 1) or vice versa, each expression gets evaulated - first on its own. Math.random() leads to an integer between 0 and less 1, while (maximum - minimum + 1)) evaluates - to 100. Then multiplication comes into place and we get floats from 0.00 and less than 100. Having Math.floor() - as a method basically means we now have random integers from 0 and 99. By considering the last part of the value - assigned to num, we now have random integers from 1 and 100 (both included). +1. Since Math.random() returns an integer in the interval [0, 1). This means num eventually represents any random integer in the interval [0, 100]. +2. Math.floor() rounds down the expression "Math.random() * (maximum - minimum + 1)"", leading to an integer in the interval [0,100). + +3. So num returns an integer in the interval [0,100) + 1 which eventually means num return [0, 100] 4. Done! */ From 1042135e5890db0a70485590b694448324ffd3a0 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:40:35 +0100 Subject: [PATCH 18/29] changed variable names to meet JS requirements --- 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 63290784a..67d2e39e9 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -3,5 +3,5 @@ // to avoid the syntax error after running the above lines of code do as below: -const ClockTime12Hour = "20:53"; -const ClockTime24hour = "08:53"; \ No newline at end of file +const clockTime24Hour = "20:53"; +const clockTime12Hour = "08:53"; \ No newline at end of file From 6dd174805f34772da48924187f4929e9725670f8 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:44:58 +0100 Subject: [PATCH 19/29] updated answer for variable declaration question --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 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 d38db4604..6c7f9a30a 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -30,7 +30,7 @@ this problem. c) line 4 & line 5 -d) line 1 & line 2 +d) lines 1, 2, 7 & 8 e) The last expression gets rid of all the commas present in the declared variables in line 1 & 2. or in other words, replaces them commas with no space between the characters separated by the commas. From a6bfabefc8d61fea90f549f59a496033bbcea2d5 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:55:55 +0100 Subject: [PATCH 20/29] rephrased my answer for the last question --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 6c7f9a30a..42a8db9f4 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -32,6 +32,5 @@ c) line 4 & line 5 d) lines 1, 2, 7 & 8 -e) The last expression gets rid of all the commas present in the declared variables in line 1 & 2. or in other words, replaces them commas with -no space between the characters separated by the commas. +e) Firstly, it replaces all commas in the string and eventually converts the new string into a number. */ From 41eff9e918451cfbb1ad9c29410018117726310d Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 16:57:02 +0100 Subject: [PATCH 21/29] updated my answer for the last question --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 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 42a8db9f4..0234cd95d 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -32,5 +32,5 @@ c) line 4 & line 5 d) lines 1, 2, 7 & 8 -e) Firstly, it replaces all commas in the string and eventually converts the new string into a number. +e) Firstly, it removes all commas in the string and eventually converts the new string into a number. */ From d94c7bd64f230842e3258f334641cfb5dbb0a340 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 17:26:42 +0100 Subject: [PATCH 22/29] rephrased my answer for Q -f --- Sprint-1/3-mandatory-interpret/2-time-format.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 16e208973..a52d13ae9 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 = -10; // length of movie in seconds +const movieLength = 0; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -27,10 +27,9 @@ console.log(result); /* a) There are 6 in total. -b) 0 function calls. +b) Only one function call "console.log(result)". c) it represents the remainder from the division of movieLength by 60. d) line 4 represents the total number of mins in the movie (as whole numbers -integers) by getting rid of the decimal parts (in secs). e) Result represents the total movie duration (in exact hours, exact min and exact sec). movieDuration could be a good name. -f) it works. However, if there's enough time to form a whole hour(s) for example the results shows the total mins and total secs and so -on. So I'd say it works. +f) Yes, It does work when trying different values of movieLength. */ From 5203cb71e5341f43178c9c3878fd6c80f5a845ec Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 18:41:11 +0100 Subject: [PATCH 23/29] changed my response to the last question --- Sprint-1/4-stretch-explore/chrome.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index dfa9c1976..ef309de5f 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -19,4 +19,4 @@ Now try invoking the function `prompt` with a string input of `"What is your nam What effect does calling the `prompt` function have? //prompt expect input from the user by showing a small window with space for input to be submitted once called. What is the return value of `prompt`? -//undefined +//a string - the name entered my the user. From 616652d4dd6b8dad4f4e21bfc1994ead6828be48 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Fri, 20 Jun 2025 18:48:12 +0100 Subject: [PATCH 24/29] changed some of my answers --- 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 725d60897..906ddb404 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -16,7 +16,7 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -//console doesn't store. it displays. +//it stores different logging, debugging, warning/errors and information properties. What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? //console.log log or display values to the console. Console.assert, check if a condition is true and in this case no output. Otherwise, an // error message shows. As for the `,`, it's called the dot notation and it's used to access properties and methods of an object. From ec148524a88c5aef335c96310afaea17bb9974de Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 23 Jun 2025 17:04:22 +0100 Subject: [PATCH 25/29] updated response to last question --- Sprint-1/4-stretch-explore/chrome.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index ef309de5f..9e0dacb22 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -19,4 +19,4 @@ Now try invoking the function `prompt` with a string input of `"What is your nam What effect does calling the `prompt` function have? //prompt expect input from the user by showing a small window with space for input to be submitted once called. What is the return value of `prompt`? -//a string - the name entered my the user. +//a string - when clicking OK and null when clicking on cancel. From 7c5701d4f07002ec519b57bf5e47dc9db92922c6 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 23 Jun 2025 17:20:02 +0100 Subject: [PATCH 26/29] corrected my response to the 4th Q --- 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 906ddb404..b9ab86fc2 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -16,7 +16,7 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -//it stores different logging, debugging, warning/errors and information properties. +//it stores different logging, debugging, warning/errors and information properties. These are properties (pairs of keys and their corresponding values). What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? //console.log log or display values to the console. Console.assert, check if a condition is true and in this case no output. Otherwise, an // error message shows. As for the `,`, it's called the dot notation and it's used to access properties and methods of an object. From c93411c753faebff2621238f759a24ba19c81862 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 23 Jun 2025 17:31:24 +0100 Subject: [PATCH 27/29] updated my responses --- Sprint-1/1-key-exercises/4-random.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 0f4feb14d..828bc5aad 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -9,9 +9,9 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try logging the value of num and running the program several times to build an idea of what the program is doing /* -1. Since Math.random() returns an integer in the interval [0, 1). This means num eventually represents any random integer in the interval [0, 100]. -2. Math.floor() rounds down the expression "Math.random() * (maximum - minimum + 1)"", leading to an integer in the interval [0,100). +1. Since Math.random() returns an integer in the interval [0, 1). This means num eventually represents any random integer in the interval [1, 100]. +2. Math.floor() rounds down the expression "Math.random() * (maximum - minimum + 1)"", leading to an integer in the interval [0,99]. -3. So num returns an integer in the interval [0,100) + 1 which eventually means num return [0, 100] +3. So num returns an integer in the interval [0,99] + 1 which eventually means num return [1, 100] 4. Done! */ From a9cdc038cea7f0bd2036e8d902179d235294a9d9 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Tue, 24 Jun 2025 20:20:44 +0100 Subject: [PATCH 28/29] updated response for "What does `console` store?" --- 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 b9ab86fc2..3777c4258 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -16,7 +16,7 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -//it stores different logging, debugging, warning/errors and information properties. These are properties (pairs of keys and their corresponding values). +//console is an object that provides a collection of methods and some properties for logging information, debugging JavaScript code, inspecting objects, timing code execution, and profiling performance. The console.log(), console.info(), console.warn(), console.error(), and console.debug() methods all accept any type of value (strings, numbers, objects, etc.) and are used for general, informational, warning, error, and debug logging respectively. console.dir() accepts an object and displays its properties in a tree format, while console.table() takes an array or object and presents it in a table. console.assert() takes a boolean condition and any value, logging the value only if the condition is false. console.count() uses a string label to count how many times it has been called. console.time() and console.timeEnd() take a string label and measure time between the two calls. console.group(), console.groupCollapsed(), and console.groupEnd() use string labels to group logs. console.trace() accepts no arguments and logs the call stack. console.profile() and console.profileEnd() take string labels and record performance data. What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? //console.log log or display values to the console. Console.assert, check if a condition is true and in this case no output. Otherwise, an // error message shows. As for the `,`, it's called the dot notation and it's used to access properties and methods of an object. From cac3613db58e7b1ca601ca1b5742383b163ec428 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Tue, 24 Jun 2025 20:23:28 +0100 Subject: [PATCH 29/29] Edited answer 4 What's the return value of prompt? --- Sprint-1/4-stretch-explore/chrome.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index 9e0dacb22..1d5dac9db 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -19,4 +19,4 @@ Now try invoking the function `prompt` with a string input of `"What is your nam What effect does calling the `prompt` function have? //prompt expect input from the user by showing a small window with space for input to be submitted once called. What is the return value of `prompt`? -//a string - when clicking OK and null when clicking on cancel. +//when ok clicked the user's input is returned otherwise in cancellation null is returned.