From 9dfbf614103b53cb63c5921d995ac6b9428a0809 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Tue, 4 Feb 2025 18:56:17 +0000 Subject: [PATCH 01/25] Added new file --- prep/Convert.js | Bin 0 -> 512 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/Convert.js diff --git a/prep/Convert.js b/prep/Convert.js new file mode 100644 index 0000000000000000000000000000000000000000..0bb9df43dc22ff8e025d72fdf4c49d5f76193cfe GIT binary patch literal 512 zcma)&K?{OF6ols-^dC$LGD7XpDY|!(4*dYlEQ(D-w=UsduV!~Omayos^4xv%y?OI| z1PI_DMS&a@BLitl)iQ5dDY4=0 zTGuJRIr|bESdHPa_imA#x7PT%bf}Dz7(*(5`JIq8qvH@YMu;2N#<7}Hk}c`H)Q-C* znLUl7{@B@0O_3^+gw9aqWM2Q--=5Jj3z9M>EtuPZDcO9l+2dQUixss(Yo~M)k)cxZ NaiYfoTxM=&z5r_MQXc>S literal 0 HcmV?d00001 From 2ae38e4f24ec57bee795ca0ee8ed94a8c4a0af49 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Tue, 4 Feb 2025 18:57:49 +0000 Subject: [PATCH 02/25] Added new file --- prep/example.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 prep/example.js diff --git a/prep/example.js b/prep/example.js new file mode 100644 index 000000000..9401bf0c3 --- /dev/null +++ b/prep/example.js @@ -0,0 +1,2 @@ +console.log("Hello, this is my JavaScript file!"); +console.log("Node.js is executing this file."); \ No newline at end of file From f4fdf3c2177179e90749c6f6bf6656e6dfd159e5 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 19:09:21 +0000 Subject: [PATCH 03/25] Sprint-1 Initials retrieving --- Sprint-1/1-key-exercises/2-initials.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..5fbe6f5d9 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,12 @@ 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. +<<<<<<< Updated upstream let initials = ``; +======= +let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; +>>>>>>> Stashed changes // https://www.google.com/search?q=get+first+character+of+string+mdn +console.log(initials); \ No newline at end of file From 5bbeaa12a0fc92e6f95b82912d4c3360b9e09c70 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:12:04 +0000 Subject: [PATCH 04/25] count-Sprint-1 Answer --- Sprint-1/1-key-exercises/1-count.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..8223aae79 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,6 @@ 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: it's adding one to the value of Variable count which is 0, in line 3 the value of count changes to 1 \ No newline at end of file From 04e19e6914dbd3741d5cc285d668a21f95afd326 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:15:02 +0000 Subject: [PATCH 05/25] Initials-Sprint1-Answer --- Sprint-1/1-key-exercises/2-initials.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 5fbe6f5d9..056adfaf9 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -9,6 +9,7 @@ let lastName = "Johnson"; let initials = ``; ======= let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; + >>>>>>> Stashed changes // https://www.google.com/search?q=get+first+character+of+string+mdn From 26ed13611e9ee7da5e3a0d7af48cb83faef42a2a Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:39:37 +0000 Subject: [PATCH 06/25] Paths-Sprint1-Answer --- Sprint-1/1-key-exercises/3-paths.js | 12 ++++++++++-- 1 file changed, 10 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..2d9d17650 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -14,10 +14,18 @@ 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 ext =filePath.slice(filePath.lastIndexOf(".")+1); + +console.log(ext); +console.log(dir); + // 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 = ; +// const ext = ; // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 5302827d528e2338449c56447982840da24e5b98 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:52:21 +0000 Subject: [PATCH 07/25] random-Sprint1-Answer --- Sprint-1/1-key-exercises/4-random.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..67ea08385 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,14 @@ 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 + + + +//Answer (before running the code): +// I believe a random number will be multiplied by 100 and added by 1 so will have 101, 201, 301, 401, 501..... +//maximum which is 100 minus minimum which is 1 and added to 1 will result to 100, 100-1+1=100, and it will be multiplied to 100 and added to minimum which is 1. + +console.log(num); + +//Answer (After running the code): +//Math.random unlike my expectations doesn't produce an integer, it produced a random Floating number between 0 and 1, so we get answer in range of 1 - 101 From 9b1a1cb8bcb42324cc920c805885c40529525d18 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:54:20 +0000 Subject: [PATCH 08/25] modified-initials-sprint1-Answer --- Sprint-1/1-key-exercises/2-initials.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 056adfaf9..59ea2e57b 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,12 +5,12 @@ 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. -<<<<<<< Updated upstream -let initials = ``; -======= + + + let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; ->>>>>>> Stashed changes + // https://www.google.com/search?q=get+first+character+of+string+mdn From 61dbd1b3eef2bb128cacac3ad8d22b4f767c9231 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 22:58:58 +0000 Subject: [PATCH 09/25] Comments-Sprint1-Answer --- Sprint-1/2-mandatory-errors/0.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..2cf94cbf2 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 +// 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 should comment them out, in VS Code the shourtcut is cntrl + c, cntrl + k. the symple of commenting out for each coding language differs and computers don't execute the lines that are commented out \ No newline at end of file From 1a13889dec36e9f1f1aed7dd9ca99833ff0ceb4f Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 23:01:03 +0000 Subject: [PATCH 10/25] const or let? Answer --- Sprint-1/2-mandatory-errors/1.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..34201c80d 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,8 @@ // 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); + +//In this case we cann't use const variable if we want to change its value later on, so it should be let \ No newline at end of file From 70b0824c3f97c15a377adee0e2466eade7098f7c Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 23:04:46 +0000 Subject: [PATCH 11/25] referrence Error-Sprint 1- Answer --- Sprint-1/2-mandatory-errors/2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..d8bf14f07 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,7 @@ // 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}`); + +//The error was Referrence Error which is cause by using a variable before declaring it. JavaScript reads from top to bottom, so we have to declare the variable first and the use it. I moved the cityOfBirth variable one line above the console.log funciton \ No newline at end of file From 1848c74e9fc9feadc85dfe6363cb3a194f1ecf7a Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 23:13:27 +0000 Subject: [PATCH 12/25] slice only for strings and array- sprint 1-Answer --- Sprint-1/2-mandatory-errors/3.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..3388492b0 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,7 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +const lastFourDigits = String(cardNumber).slice(-4); + +console.log(lastFourDigits); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +9,7 @@ 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 + + +//Prediction and explaination: +//index value is only for string and array data types, in this case it throws an error since cardNumber holds a number not string or arrray. \ No newline at end of file From e4d0f87ea8edc5d804013cfa0be324d98880587c Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Wed, 5 Feb 2025 23:15:30 +0000 Subject: [PATCH 13/25] no numeric values for variables' name-sprint 1-Answer --- 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..f0ab94e12 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 twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; \ No newline at end of file From dffe519b811220ae479ec71f8f10bd6c5b5d631c Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 17:31:40 +0000 Subject: [PATCH 14/25] Percentage Change-Sprint1- Answer --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 9 ++++++++- 1 file changed, 8 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..e729ddcb4 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,18 @@ 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 +// 2 function calls: Numbers(), variable.replaceAll(). // 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? +//On Output and Problems Console tabs, it said on line 5, a comma was missing, after comparing with the upper line that has the same function, I added a comma to separate the arguments that were passed to the function. + // c) Identify all the lines that are variable reassignment statements +// Line 4 and 5, because we are assigning a new value to the variables that are already declared in the previous line (1 and 2) // d) Identify all the lines that are variable declarations +// line 1,2,7,8 + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +//Number convert the current values ,in both variables declared in line 1 and 2, to number after removing comma from the values From 110186e9988faf80a30758327d1b2da67291ed89 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 17:34:20 +0000 Subject: [PATCH 15/25] Modified Percentage Change- Sprint 1 --- 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 e729ddcb4..8c8e53ff0 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,7 +12,7 @@ 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 -// 2 function calls: Numbers(), variable.replaceAll(). +// 3 function calls: Numbers(), variable.replaceAll(), and console.log // 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? //On Output and Problems Console tabs, it said on line 5, a comma was missing, after comparing with the upper line that has the same function, I added a comma to separate the arguments that were passed to the function. From 5697536a516f1704c0e8399d188463dc849a3246 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 17:58:44 +0000 Subject: [PATCH 16/25] time format-Sprint 1- Answer --- Sprint-1/3-mandatory-interpret/2-time-format.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..f7044e264 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,23 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +// Answer: 6 variables: line 1,3,4,6,7,9, wherever there is const or let word // b) How many function calls are there? +// Answer: only 1: 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 +//Answer: the expression will divide movieLength which is second to 60 and extract the REMAINDER of the operation. The remainder in this case can have a range of values between 0-59s + // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +//Answer: in line four we are subtracting the remainder of movieLength divided by 60 to make a divisible number by 60, because we want to know how many minutes the movieLength is in minute not second unit and minutes should be integer not float. + // e) What do you think the variable result represents? Can you think of a better name for this variable? +// Answer: the length of the movie in the following format: hr:min:sec, movieLength would be an appropriate alternative for this variable, however since we already have a variable with the same name and const type which the value cannot be changed, "displayTime" is the best name that reaches my mind. + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +//Answer: Yes I believe it would work for all the values, since we divide the movieLength by 60 one time to get the minutes and two time to get the hours, if we have a 0 second movie the calculation would still run without throwing an error since 0 is not in the denominator and is numerator. \ No newline at end of file From 22e82d7019af497099917de30a9a32cf3aa0c9a8 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 18:22:06 +0000 Subject: [PATCH 17/25] to pounds-Sprint1- Answer --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 5 +++++ 1 file changed, 5 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..acb328616 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,8 @@ 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): extract every characters in penceString variable except the last one (penceString,length -1) +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensures that the number is at least 3 digit long and if not adds 0 before the number not to change the value. +// 4.const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2): extract everything but the last 2 digits (-2) from paddedPenceNumberString variable to get the pound number +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): similar to pound, it extract the last two digits of paddedPenceNumberString to get the pence number, If there’s only one digit, it ensures two digits by adding a trailing zero +// 6. console.log(`£${pounds}.${pence}`): in this line the pound value will be displayed to the user in this format: £ pound. pence From 28e796a160fe249b465433de0076f22262f1149d Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 18:35:33 +0000 Subject: [PATCH 18/25] Modified-Not using numeric values in declaration-sprint 1 --- Sprint-1/2-mandatory-errors/4.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index f0ab94e12..0b980c02c 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,4 @@ const twelveHourClockTime = "20:53"; -const twentyFourHourClockTime = "08:53"; \ No newline at end of file +const twentyFourHourClockTime = "08:53"; + +//Answer: we can declare or name our variables using numeric values \ No newline at end of file From 83efda8af63233ed6797a36c4c692c0ca2f2f6c4 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Thu, 6 Feb 2025 18:45:19 +0000 Subject: [PATCH 19/25] Answer to object-Sprint1 --- Sprint-1/4-stretch-explore/objects.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..e0a151039 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,16 @@ 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? +undefined if () were typed +ƒ log() { [native code] } if () were not typed 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? +What does `console` store? some functions that can be called like "log" +What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? we are calling asset or log function from console which stores these functions From b5c7e0f0c460088e4311128ce065c14cf2016634 Mon Sep 17 00:00:00 2001 From: hatef Eidi Date: Fri, 7 Feb 2025 20:22:11 +0000 Subject: [PATCH 20/25] Chrome Alert and Prompt-Sprint1-Answer --- 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..b6ad1df32 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 pop-up box will appear with the text of 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 pop-up box will appear with the text what is your name? and input text box to let the user type their names + What is the return value of `prompt`? +The input of the what is your name pop-up text From e07ec38305e9898a1e5c360aec5d644a4c41292c Mon Sep 17 00:00:00 2001 From: Hatef Eidi Date: Tue, 18 Feb 2025 13:55:58 +0000 Subject: [PATCH 21/25] math.random() exploration --- 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 67ea08385..e1ab815c6 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -17,4 +17,4 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; console.log(num); //Answer (After running the code): -//Math.random unlike my expectations doesn't produce an integer, it produced a random Floating number between 0 and 1, so we get answer in range of 1 - 101 +//Math.random unlike my expectations doesn't produce an integer, it produced a random Floating number between 0 and 1, so we get answer in range of 1 - 100 From 6c29b8118eb8bcab4aaa84e883d7a3c987065480 Mon Sep 17 00:00:00 2001 From: Hatef Eidi Date: Tue, 18 Feb 2025 14:02:14 +0000 Subject: [PATCH 22/25] Naming Variables --- Sprint-1/2-mandatory-errors/4.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 0b980c02c..abe7ea6e9 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,4 +1,5 @@ const twelveHourClockTime = "20:53"; const twentyFourHourClockTime = "08:53"; -//Answer: we can declare or name our variables using numeric values \ No newline at end of file +//Answer: we can declare or name our variables using numeric values, but we can't start with a number, so we can't name our variables as 20:53 or 08:53 +// Furthermore, the variable's name doesn't match the content of the variables and the naming should be opposite, to match the content of the values. \ No newline at end of file From 64244508c430e0ff305e1cbf30662edde34ba684 Mon Sep 17 00:00:00 2001 From: Hatef Eidi Date: Tue, 18 Feb 2025 14:06:19 +0000 Subject: [PATCH 23/25] Choosing the bast variable name- remainingDisplayDisplayTime --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 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 f7044e264..eb01dc618 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -27,7 +27,7 @@ console.log(result); // e) What do you think the variable result represents? Can you think of a better name for this variable? -// Answer: the length of the movie in the following format: hr:min:sec, movieLength would be an appropriate alternative for this variable, however since we already have a variable with the same name and const type which the value cannot be changed, "displayTime" is the best name that reaches my mind. +// Answer: the length of the movie in the following format: hr:min:sec, movieLength would be an appropriate alternative for this variable, however since we already have a variable with the same name and const type which the value cannot be changed, "remainingDisplayTime" is the best name that reaches my mind. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer From 1ebe90048a044753e8a696e65c964ba8122ef54d Mon Sep 17 00:00:00 2001 From: Hatef Eidi Date: Tue, 18 Feb 2025 14:21:16 +0000 Subject: [PATCH 24/25] The out-put of prompt --- Sprint-1/4-stretch-explore/chrome.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index b6ad1df32..894d89572 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -17,6 +17,9 @@ Now try invoking the function `prompt` with a string input of `"What is your nam What effect does calling the `prompt` function have? A pop-up box will appear with the text what is your name? and input text box to let the user type their names +If they press cancel, whether or not they have entered their name in the text box- in the console we will see the 'null' in the next line of the prompt +If they enter their name, and press ok, in the console they can view their name. What is the return value of `prompt`? The input of the what is your name pop-up text +If they enter their name, and press ok, in the console they can view their name. \ No newline at end of file From 6dc8e6790a75fa778c90200021d6cb03b3b347dc Mon Sep 17 00:00:00 2001 From: Hatef Eidi Date: Tue, 18 Feb 2025 14:28:52 +0000 Subject: [PATCH 25/25] Accessing a function within an object using: object.function() approach --- Sprint-1/4-stretch-explore/objects.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index e0a151039..777ff03bb 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -17,4 +17,5 @@ object Answer the following questions: What does `console` store? some functions that can be called like "log" -What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? we are calling asset or log function from console which stores these functions +What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +we are calling assert or log function from console which stores these functions. The "." tells the program to access the console object and call the function log, or assert within console object.