From ae2a475918126001eac3d0bb4dd0da953b811866 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Fri, 27 Feb 2026 02:23:52 +0000 Subject: [PATCH 01/13] solving some practice before moving to course work --- Sprint-1/1-key-exercises/1-count.js | 4 ++++ Sprint-1/1-key-exercises/2-initials.js | 3 ++- Sprint-1/1-key-exercises/3-paths.js | 9 +++++---- Sprint-1/1-key-exercises/4-random.js | 9 +++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..ce1c4be737 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,6 +1,10 @@ let count = 0; count = count + 1; +/* in line three, the variable count is combining the variable count original value of 0 with new value of 1 with the used of plus operator. +The equal operator is this case helping to re-assign the new value back to the count variable +*/ +console.log(count); // 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 diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..568e64d2b5 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,8 @@ 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.slice(0,1)+middleName.slice(0,1)+lastName.slice(0,1); +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..e43f844ee6 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,8 +16,9 @@ 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 slashIndex = filePath.indexOf("/"); +const dir =filePath.slice(slashIndex + 0, 45) ; +const ext =filePath.slice(slashIndex + 49, 53); +console.log(`The dir part of ${filePath} is ${dir}`); +console.log(`The ext part of ${filePath} is ${ext}`); // https://www.google.com/search?q=slice+mdn \ 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 292f83aabb..5133cbed38 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -3,7 +3,16 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; +console.log(num) + // In this exercise, you will need to work out what num represents? // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing + +/*Number data type represents any type of number such as integer, float number(decimal number), infinity number, etc... +In the code at line 4 the num variable are doing math function that generate a integer between variable minimum and maximum value, +the floor method behind the Math are is main purpose if to help turn value of a float number and round it up to the nearest integer. +inside the Math.floor parameter the math random method is choosing a random float number between 0 and 1 and have it multiply with the second expression +to set the range of possible value range from 0 to under 100. The last plus one to make sure the that number stay above 0(0+1) and to 100(99+1); +*/ \ No newline at end of file From 20fb21587ef2029282f14dd9ca18ea98672676e6 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 28 Feb 2026 01:07:54 +0000 Subject: [PATCH 02/13] Doing some error change that in section 2 of sprint 1 --- Sprint-1/2-mandatory-errors/0.js | 6 ++++-- Sprint-1/2-mandatory-errors/1.js | 8 ++++++-- Sprint-1/2-mandatory-errors/2.js | 4 ++++ Sprint-1/2-mandatory-errors/3.js | 4 +++- Sprint-1/2-mandatory-errors/4.js | 8 ++++++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..eb485e19f8 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? +By comment both the line 1 and 2 out and the system should ignore these 2 line and see them as comment. +*/ \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..ffeff12b1d 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; -age = age + 1; +let age = 33; +age = ++age; + +console.log(age); + +/*By changing the variable from const to let since const variable value can't be change. I used prefix to increase the value and reassign it right away.*/ \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..45eda0213b 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,7 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +/*the main the error here is that the console.log try to print the expression string template with the variable cityOfBirth. But since in the variable +cityOfBirth declare after the console.log, so the console.log when try to involve the cityOfBirth will return error since the it doesn't exist. +*/ diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..8b3dfb4555 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 last4Digits = Number(cardNumber.toString().slice(-4)); +console.log(last4Digits); +console.log(typeof last4Digits); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d1..7ff0813bd4 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,6 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const $12HourClockTime = "20:53"; +const $24HourClockTime = "08:53"; +console.log($12HourClockTime); +console.log($24HourClockTime); + +/*For this error I I fix by add $(money-sign)before the 12 and 24 variable name because in JS number can't be used to begin writing a variable name */ \ No newline at end of file From ba2b449277827c0cd707386daae8106d75fe031c Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 28 Feb 2026 16:26:31 +0000 Subject: [PATCH 03/13] This commit is for section 3 of sprint 1 brach --- .../1-percentage-change.js | 29 ++++++++++++++++++- 1 file changed, 28 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 e24ecb8e18..a36dc7628a 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,30 @@ 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? + +/* +Answer +a) In this section of the code, we have function calls appear 5 time through out the code. Here is each of them on the line of code that +they are call: + - Number(carPrice.replaceAll(",","")); in line 4 is a function calls because the .replaceALL is being executed + - Number(priceAfterOneYear.replaceAll(",", "")); in line 5 is also a function call because .replaceAll is being executed. + - Inside the Number() function the .replaceAll in both line 4 and 5 is also a function call because the the parent function is also + being executed. + - the console.log is a function calls +So the total amount of function call in this code is 5 + +b) The main error for the when the running this line of code if for the missing right parameter after the double quote, so fix this +just add the coma right after the double quote. + +c) There are 2 reassign variable statement at line 4 and line 5. + +d)There are 4 total variable declarations in this code: + - let carPrice = "10,00"; line 1 + - let priceAfterOneYear ="8,543"; line 2 + - const priceDifference = carPrice - priceAfterOneYear; line 7 + - const percentageChange = (priceDifference / carPrice) * 100; line 8 + +e) The expression Number(carPrice.replaceAll(",","")) are doing 2 main purpose, + - The first purpose is to remove the coma from the string number "10000" and "8543". + - Is the changing the string number to number data type. +*/ \ No newline at end of file From 4a643cc5c36250aa044b3e5c33d71af362be9248 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 1 Mar 2026 01:45:51 +0000 Subject: [PATCH 04/13] Finish movieLength course work and push it to repo --- .../3-mandatory-interpret/2-time-format.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..b87a2c760f 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -23,3 +23,31 @@ 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 + +/* +Answer +a)In this program there are 5 variable declarations: + -const movieLength = 8784; at line 1. + -const remainingSeconds = movieLength % 60; at line 3. + -const totalMinutes = (movieLength - remainingSeconds) / 60; at line 4. + -const remainingMinutes = totalMinutes % 60; at line 6. + -const totalHours = (totalMinutes - remainingMinutes) / 60; at line 7. + +b) There are only 1 function call in this program. + - console.log(result); at line 10 + +c)At the line 3 we can see the the expression movieLength % 60, +what is represent is the reminder value after the division movieLength(in second) value by 60%; +this is to remind how much left over second left in the movie. + +d)In line 4, the the expression that is assigned to totalMinutes +represent the value after the math operation if movieLength value and remainingSeconds then divine by 60; + +e)For the variable result it represent the combine total time length of the movie in hour/minutes/second template, for better name for this variable +I would to rename it to totalMovieLength. + +f) After the experimenting with different values of movieLength. As Long as the value in movieLength is a positive integer of second. It will +correctly produce the correct value in hours/minutes/second format. However for to the other value such as float number, string, negative integer +and non numeric value. They might still print out in the format hours/minutes/second but some type will break code such as if string not a number or coma in a string +number, negative value that don't reflect what this code try to do or decimal number that give incorrect result. +*/ \ No newline at end of file From 8d780b872566412aeef760f9ed7d26c866019640 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Mon, 2 Mar 2026 03:08:03 +0000 Subject: [PATCH 05/13] Finish the last exercise of the section 3 sprint course work and ready for the PR --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..fbf4af92b4 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,4 +24,31 @@ 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: this variable is now store a new value of penceString "399". +By using the .substring method(.slice method predecessor)it remove the p from the penceString value and +reassign the new value to variable penceStringWithoutTrailingP. It start from index position 0 in this case "3" and stop at the index 2 "9". + +3. const paddedPenceNumberString: this variable main role is to check if the string value total length +at least 3, if the length short then padStart will add 0 the left from the first index(0) in this case "3" until the string length total is 3. In this case +it select the string number "3". + +4. const pounds: this variable is role is to extract the pound value from the paddedPenceNumberString. +Inside the the paddedPenceNumberString subString method parameter it have 2 value 0 and paddedPenceNumberString total string length minus 1, +the 0 is the index of the string number that we would like to start while .length - 2 is to tell the SubString method where to stop in this case the first "9". + +5) const pence: as the name suggest this variable main role is to extract he pence value from the paddedPenceNumberString variable. +How ever this variable there are 2 method is used. + -subString method is used to slice the string value "99" off the "399" value, how ever is now only have 1 value + is the length of the "399" is 3 now - 2 equal to 1 and no end value. The main reason is to select where the slice will begin stop at the end + of the string. + -padEnd method work exactly the same as padStart but in reverse. The padEnd method is checking to see is the paddedPenceNumberString string length at least total of 2, + if not they will add 0 from the selected index position from the string value "99" from the index 0 in this case is "9" to the right. + +6)console.log(`£${pounds}.${pence}`): is to log and print out the value inside the terminal by using the string template, the back tick is to +define a template literal. Then inside the template the pound sign(£) is show the pound currency, the money sign before the curly bracket is to allow +embed variables in this case pounds and pence that separate by dot that print out a float string value. +*/ + \ No newline at end of file From 54de2415d09e4f9f2ebd4ab6992e10517f0fa68c Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 15 Mar 2026 01:47:04 +0000 Subject: [PATCH 06/13] Fixing the first 3 work from 1-key-excercise --- Sprint-1/1-key-exercises/1-count.js | 3 +-- Sprint-1/1-key-exercises/2-initials.js | 2 +- Sprint-1/1-key-exercises/3-paths.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index ce1c4be737..2711fd1506 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,8 +1,7 @@ let count = 0; count = count + 1; -/* in line three, the variable count is combining the variable count original value of 0 with new value of 1 with the used of plus operator. -The equal operator is this case helping to re-assign the new value back to the count variable +/* in line three, the variable count is reassign new value by increment it current value by 1. */ console.log(count); diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 568e64d2b5..10cc52f0ab 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 = firstName.slice(0,1)+middleName.slice(0,1)+lastName.slice(0,1); +let initials = firstName.charAt(0)+middleName.charAt(0)+lastName.charAt(0); console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index e43f844ee6..03fbc095a7 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,9 +16,24 @@ 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 slashIndex = filePath.indexOf("/"); const dir =filePath.slice(slashIndex + 0, 45) ; const ext =filePath.slice(slashIndex + 49, 53); console.log(`The dir part of ${filePath} is ${dir}`); console.log(`The ext part of ${filePath} is ${ext}`); +*/ + +function pathFinder(path){ + const lastSlash = path.lastIndexOf("/"); + const dir = path.slice(0, lastSlash); + const base = path.slice(lastSlash + 1); + const dot = base.lastIndexOf("."); + const ext = dot !== -1 ? base.slice(dot) : ""; + + return { dir, base, ext }; +} + +console.log(pathFinder(filePath)); + // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 62e8714d01b0ea11e9b2adc652aeb87a92a553bd Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Wed, 18 Mar 2026 17:10:19 +0000 Subject: [PATCH 07/13] basic change --- Sprint-1/1-key-exercises/3-paths.js | 34 ++++++++++++++++++++++------- Sprint-1/2-mandatory-errors/1.js | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 03fbc095a7..9acc7d944a 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -24,14 +24,32 @@ console.log(`The dir part of ${filePath} is ${dir}`); console.log(`The ext part of ${filePath} is ${ext}`); */ -function pathFinder(path){ - const lastSlash = path.lastIndexOf("/"); - const dir = path.slice(0, lastSlash); - const base = path.slice(lastSlash + 1); - const dot = base.lastIndexOf("."); - const ext = dot !== -1 ? base.slice(dot) : ""; - - return { dir, base, ext }; +function pathFinder(userInput, filePath){ + // 1. Check if the user input exists inside the full path + if (!fullPath.includes(userInput)) { + console.log("Input not found in path"); + return; + } + + // 2. Split the path into parts + const parts = filePath.split("/"); + + // 3. Base = last element + const base = parts[parts.length - 1]; + + // 4. Dir = everything except the last element + const dir = parts.slice(0, parts.length - 1).join("/"); + + // 5. Extension logic + const dotIndex = base.lastIndexOf("."); + const ext = dotIndex === -1 ? "" : base.slice(dotIndex); + + // 6. Print everything + console.log(`Full path: ${filePath}`); + console.log(`Directory: ${dir}`); + console.log(`Base: ${base}`); + console.log(`Extension: ${ext}`); + } console.log(pathFinder(filePath)); diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index ffeff12b1d..cde1389328 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,7 +1,7 @@ // trying to create an age variable and then reassign the value by 1 let age = 33; -age = ++age; +age = age++; console.log(age); From 041e4fc49880d76b15c97cf056f156e7f53e230a Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 21 Mar 2026 23:54:10 +0000 Subject: [PATCH 08/13] Refix 1.js in second section. --- 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 cde1389328..3c88f39b3d 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,7 +1,7 @@ // trying to create an age variable and then reassign the value by 1 let age = 33; -age = age++; +age += 1 ; console.log(age); From 1f147ebfe02e9ea9d94d4c6c0e5a3dbcb0f16c55 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 22 Mar 2026 00:09:08 +0000 Subject: [PATCH 09/13] 3-paths.js fixing --- Sprint-1/1-key-exercises/3-paths.js | 35 +++++------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 9acc7d944a..4c6b41eede 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -23,35 +23,10 @@ const ext =filePath.slice(slashIndex + 49, 53); console.log(`The dir part of ${filePath} is ${dir}`); console.log(`The ext part of ${filePath} is ${ext}`); */ - -function pathFinder(userInput, filePath){ - // 1. Check if the user input exists inside the full path - if (!fullPath.includes(userInput)) { - console.log("Input not found in path"); - return; - } - - // 2. Split the path into parts - const parts = filePath.split("/"); - - // 3. Base = last element - const base = parts[parts.length - 1]; - - // 4. Dir = everything except the last element - const dir = parts.slice(0, parts.length - 1).join("/"); - - // 5. Extension logic - const dotIndex = base.lastIndexOf("."); - const ext = dotIndex === -1 ? "" : base.slice(dotIndex); - - // 6. Print everything - console.log(`Full path: ${filePath}`); - console.log(`Directory: ${dir}`); - console.log(`Base: ${base}`); - console.log(`Extension: ${ext}`); - -} - -console.log(pathFinder(filePath)); + +let dirDirectory = filePath.slice(filePath.indexOf("/"),filePath.lastIndexOf("/")); +let extDirectory = filePath.slice(filePath.lastIndexOf("/")); +console.log(`The dir part of the file is ${dirDirectory}.`); +console.log(`The ext part of the file is ${extDirectory}.`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 9fbf2805ecefcc216477df99aee3d72e955712ba Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 22 Mar 2026 01:13:03 +0000 Subject: [PATCH 10/13] fixing the cardNumber problem. --- 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 8b3dfb4555..6c8f8ece80 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 = Number(cardNumber.toString().slice(-4)); +const cardNumber = 4533787178990001; +const last4Digits = cardNumber.toString().slice(-4); console.log(last4Digits); console.log(typeof last4Digits); From fcb1b977140e06d46206b37c44ab55b44e72aaba Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 22 Mar 2026 01:14:50 +0000 Subject: [PATCH 11/13] Quick change to the original cardNumber --- Sprint-1/2-mandatory-errors/3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index 6c8f8ece80..3872d807a8 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ -const cardNumber = 4533787178990001; +const cardNumber = 4533787178994213; const last4Digits = cardNumber.toString().slice(-4); console.log(last4Digits); console.log(typeof last4Digits); From 1f8489ed7b678c8524992c052a285152d3433c2a Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sun, 22 Mar 2026 01:47:15 +0000 Subject: [PATCH 12/13] Finished the last 3 part need to change for PR review --- Sprint-1/2-mandatory-errors/4.js | 6 +++--- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 7ff0813bd4..0a22b02ff0 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,6 +1,6 @@ -const $12HourClockTime = "20:53"; -const $24HourClockTime = "08:53"; +const twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; console.log($12HourClockTime); console.log($24HourClockTime); -/*For this error I I fix by add $(money-sign)before the 12 and 24 variable name because in JS number can't be used to begin writing a variable name */ \ No newline at end of file +/*For this error I I fix by changing the number 12 and 24 to word variable name because in JS number can't be used to begin writing a variable name */ \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index a36dc7628a..76c80706bb 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -32,7 +32,7 @@ they are call: - the console.log is a function calls So the total amount of function call in this code is 5 -b) The main error for the when the running this line of code if for the missing right parameter after the double quote, so fix this +b) The main error for the when the running this line of code if for the missing right parameter between the arguments, so fix this just add the coma right after the double quote. c) There are 2 reassign variable statement at line 4 and line 5. diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index b87a2c760f..d0c275d6fa 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -44,7 +44,7 @@ d)In line 4, the the expression that is assigned to totalMinutes represent the value after the math operation if movieLength value and remainingSeconds then divine by 60; e)For the variable result it represent the combine total time length of the movie in hour/minutes/second template, for better name for this variable -I would to rename it to totalMovieLength. +I would to rename it to formattedMovieDuration. f) After the experimenting with different values of movieLength. As Long as the value in movieLength is a positive integer of second. It will correctly produce the correct value in hours/minutes/second format. However for to the other value such as float number, string, negative integer From fd5b31a54027eaa6f5b2af80264340229d60878c Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Mon, 23 Mar 2026 02:55:52 +0000 Subject: [PATCH 13/13] Making chang for requesting pr review again. --- Sprint-1/1-key-exercises/3-paths.js | 15 +++++---------- Sprint-1/1-key-exercises/4-random.js | 19 ++++++++++++++----- Sprint-1/2-mandatory-errors/4.js | 4 ++-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 4c6b41eede..f6538a9037 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,17 +16,12 @@ 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 slashIndex = filePath.indexOf("/"); -const dir =filePath.slice(slashIndex + 0, 45) ; -const ext =filePath.slice(slashIndex + 49, 53); -console.log(`The dir part of ${filePath} is ${dir}`); -console.log(`The ext part of ${filePath} is ${ext}`); -*/ + -let dirDirectory = filePath.slice(filePath.indexOf("/"),filePath.lastIndexOf("/")); -let extDirectory = filePath.slice(filePath.lastIndexOf("/")); +let dirDirectory = filePath.slice(filePath.indexOf("/"),filePath.lastIndexOf(".")); +let extDirectory = filePath.slice(filePath.lastIndexOf(".")); +let baseDirectory = filePath.slice(filePath.lastIndexOf("/")); console.log(`The dir part of the file is ${dirDirectory}.`); console.log(`The ext part of the file is ${extDirectory}.`); - +console.log(`The base part of the file is ${baseDirectory}.`); // https://www.google.com/search?q=slice+mdn \ 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 5133cbed38..16ae3debda 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -10,9 +10,18 @@ console.log(num) // 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 -/*Number data type represents any type of number such as integer, float number(decimal number), infinity number, etc... -In the code at line 4 the num variable are doing math function that generate a integer between variable minimum and maximum value, -the floor method behind the Math are is main purpose if to help turn value of a float number and round it up to the nearest integer. -inside the Math.floor parameter the math random method is choosing a random float number between 0 and 1 and have it multiply with the second expression -to set the range of possible value range from 0 to under 100. The last plus one to make sure the that number stay above 0(0+1) and to 100(99+1); +/* +Generates a random integer within the inclusive range [minimum, maximum]. + +How the range is formed: + +Math.random() returns a float in the interval [0, 1) + +Multiplying by (maximum - minimum + 1) scales it to [0, maximum - minimum + 1) + +Math.floor(...) converts that to an integer in [0, maximum - minimum] + +Adding minimum shifts the range to [minimum, maximum] + +The final result is always an integer between minimum and maximum, inclusive. */ \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 0a22b02ff0..ce00d1db67 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,6 +1,6 @@ const twelveHourClockTime = "20:53"; const twentyFourHourClockTime = "08:53"; -console.log($12HourClockTime); -console.log($24HourClockTime); +console.log(twelveHourClockTime); +console.log(twentyFourHourClockTime); /*For this error I I fix by changing the number 12 and 24 to word variable name because in JS number can't be used to begin writing a variable name */ \ No newline at end of file