From 884ddbe7bd5aca925c869c7043497612096b782f Mon Sep 17 00:00:00 2001 From: abduhasen Date: Thu, 19 Feb 2026 13:42:01 +0000 Subject: [PATCH 1/5] I described the line of code in the given code format --- Sprint-1/1-key-exercises/1-count.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..dc2eaccc2 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,4 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing +// line 3 is reassigning the value of the variable, = sign is used to reassign the count to initial value of 0 + the additional value of 1 From bc09a5bcf181bdb4832524e7b26264625b88862c Mon Sep 17 00:00:00 2001 From: abduhasen Date: Thu, 19 Feb 2026 14:15:33 +0000 Subject: [PATCH 2/5] on line 8 Declare a variable called initials that stores the first character of each string --- Sprint-1/1-key-exercises/2-initials.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..4ad18c1b5 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,6 @@ 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 939f52f70002db4c3f84432f8daf83b4d976e4d4 Mon Sep 17 00:00:00 2001 From: abduhasen Date: Sat, 21 Feb 2026 15:37:33 +0000 Subject: [PATCH 3/5] I have completed --- Sprint-1/1-key-exercises/1-count.js | 2 +- Sprint-1/1-key-exercises/3-paths.js | 10 ++++++---- Sprint-1/1-key-exercises/4-random.js | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index dc2eaccc2..11a6faa73 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,4 +4,4 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing -// line 3 is reassigning the value of the variable, = sign is used to reassign the count to initial value of 0 + the additional value of 1 +// line 3 is reassigning the value of the variable, = sign is used to reassign the value of count to increment by 1. diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..e2d363d34 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,8 +16,10 @@ 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 secondCharacterIndex = 1; +const startingPointForExtension = filePath.lastIndexOf("."); -const dir = ; -const ext = ; - -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +const dir = filePath.slice(secondCharacterIndex, lastSlashIndex); +const ext = filePath.slice(startingPointForExtension + 1, filePath.length); +console.log(`The dir part of ${filePath} is ${dir} and the ext part is ${ext}`); +// https://www.google.com/search?q=slice+mdn diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..f351a4bd9 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,9 @@ 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 + +/*num represent any value between 1 to 100. +Math.floor is a method that rounds a number down to the nearest whole number. +Math.random is a method returning any number that is greater than or equal to 0 and less than 1. +first of all i will try to get a value from 0 to less than 1 from Math.random and multiple it by 100 +and apply Math.floor to the result which will give me the integer number and then add the minimum value i.e. 1 */ From 540b62a7ab775beef1aa741f44914cbf51fbe70e Mon Sep 17 00:00:00 2001 From: abduhasen Date: Sat, 21 Feb 2026 15:41:04 +0000 Subject: [PATCH 4/5] I completed key exercises for sprint-1 --- 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 f351a4bd9..44f0a3d60 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -12,4 +12,4 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; Math.floor is a method that rounds a number down to the nearest whole number. Math.random is a method returning any number that is greater than or equal to 0 and less than 1. first of all i will try to get a value from 0 to less than 1 from Math.random and multiple it by 100 -and apply Math.floor to the result which will give me the integer number and then add the minimum value i.e. 1 */ +and apply Math.floor to the result which will give me the integer number and then add the minimum value i.e. 1 */ From 0db337ad3ce7d94de57d995106d4f8709c5cd801 Mon Sep 17 00:00:00 2001 From: abduhasen Date: Mon, 23 Feb 2026 20:45:21 +0000 Subject: [PATCH 5/5] work on errors,identifying codes and brief explanation of codes --- Sprint-1/2-mandatory-errors/0.js | 6 +++-- Sprint-1/2-mandatory-errors/1.js | 3 ++- Sprint-1/2-mandatory-errors/2.js | 6 +++-- Sprint-1/2-mandatory-errors/3.js | 5 +++- Sprint-1/2-mandatory-errors/4.js | 6 +++-- .../1-percentage-change.js | 15 ++++++++++++ .../3-mandatory-interpret/2-time-format.js | 9 +++++++ Sprint-1/3-mandatory-interpret/3-to-pounds.js | 24 ++++++++++++++++++- 8 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..a852506e4 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? */ + +/*when we try to write comment and instruction and we want the computer not to run it we can comment them using // for single line and /* for multiple lines. */ diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..1a732302a 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; +// To reassign a value of age we have to use let not const. diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..d06c83e0f 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 code try to log the variable before declaring the variable +// if we declare and initialize the variable first then we can use it. diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..41d489ebe 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber @@ -7,3 +7,6 @@ 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 +/* the code is not working because of the variable type which is .slice method work on +string and array variable types not on number variable types to fix it we can change the variable type to +string variable type by adding double quotation marks to the variable.*/ diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..ffa17acb5 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,4 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const hourClockTime12 = "20:53"; +const hourClockTime24 = "08:53"; + +// Numbers are not allowed as the first character in naming of variables. diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..e156ed886 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,26 @@ 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 +/* there are 5 function calls in this code. + 1) Number(carPrice.replaceAll(",","")); line 4. + 2) Number(priceAfterOneYear.replace("," "")) line 5. + 3) carPrice.replaceAll(",", "") line 4. + 4) priceAfterOneYear.replaceAll("," "") line 5. + 5) console.log(`The percentage change is ${percentageChange}`); line 10. */ // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? +//the error is coming from line 5 and the error is missing between the arguments. // c) Identify all the lines that are variable reassignment statements +/*on line 4- carPrice = Number(carPrice.replaceAll(",", "")); + on line 5- priceAfterOneYear = Number(priceAfterOneYear.replaceAll(","), "")*/ // d) Identify all the lines that are variable declarations +/* line 1- let carPrice = "10,000"; + line 2- let priceAfterOneYear = "8,543"; + line 7- const priceDifference = carPrice - priceAfterOneYear; + line 8- const percentageChange = (priceDifference / carPrice) * 100;*/ // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +/* the expression doing changing the value of "10,000" to "10000" because comma count as part of a character after that + changing the string variable type to number variable type. */ diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..d7f916fd6 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? +// there are 6 variable declaration. // b) How many function calls are there? +// there is only one 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 +/* the expression movieLength % 60 represents the returns of the remainder after dividing one number by another + in this case 8784 % 60 and it return the remainder 24. */ // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +//This expression calculates the total full minutes in the movie by removing leftover seconds and converting seconds to minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +//result represent the total movie length using hours,minutes and seconds,the better name can be totalMovieLength. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +/*the code works for different values of movieLength it present the input movieLength by calculating the remainder and subtracting +it with the initial input and using the method for the finding of the value for the rest of the variables and assign the values withe +the variables of hours,minutes and seconds */ diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..fa89225d2 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,4 +24,26 @@ console.log(`£${pounds}.${pence}`); // Try and describe the purpose / rationale behind each step // To begin, we can start with -// 1. const penceString = "399p": initialises a string variable with the value "399p" +// 1. const penceString = "399p": initializes a string variable with the value "399p" + +/* 2. const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 + ); : this part of the code have two steps, + - inside assigning of variable there is a function call that replace the string "399p" by "399" + - then assigning the variable penceStringWithoutTrailingP with new string "399" */ + +/* 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); this initializes new string value that have + 3 character if it's less than 3 it will add "0" in front of the string.*/ + +/* 4. const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 + ); : this part of the code assigning const pound with value of string that length is + reduced by -2 . */ + +/* 5. const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); : let's break it down this code parts it have two steps first one is .substring(paddedPenceNumberString.length - 2) + Takes the last 2 characters of the string and the second is .padEnd(2, "0") Ensures the result + is at least length 2 if the length less than 2 it will add 0 at the end of the string. */