From c36d5b3c106f4c528b5fe9e48d495b2d783a04d1 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Mon, 11 Nov 2024 18:46:41 +0000 Subject: [PATCH 01/32] Debug exercise 0.js undefined function values --- Sprint-2/debug/0.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sprint-2/debug/0.js b/Sprint-2/debug/0.js index b46d471a8..c931178c1 100644 --- a/Sprint-2/debug/0.js +++ b/Sprint-2/debug/0.js @@ -1,7 +1,25 @@ // Predict and explain first... +/*it will print +the first console.log (a * b) which will call the function inputs 10, 32 = 320 + +Then give a error/ undefined because . + function multiply(a, b) { console.log(a * b); } console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); + +DEBUG*/ + +//The result of multiplying 10 and 32 is 320 + +function multiply(a, b) { + return a * b; +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); + + + From fe4ebe88336ec9cf78727f9b7bda2423bbc0159b Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Mon, 11 Nov 2024 18:47:19 +0000 Subject: [PATCH 02/32] Debug error line "return" --- Sprint-2/debug/1.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-2/debug/1.js b/Sprint-2/debug/1.js index df4020cae..25f24579e 100644 --- a/Sprint-2/debug/1.js +++ b/Sprint-2/debug/1.js @@ -1,8 +1,21 @@ // Predict and explain first... +/*It will print a error as return is in one line and Javasript will Not +read any code after that line + + function sum(a, b) { return; a + b; } +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);*/ + +//FIX:// + +function sum(a, b) { + return; a + b; +} + console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); + From 03b3c5e718058041c9c470c93ccf8dedb7409e33 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 07:32:31 +0000 Subject: [PATCH 03/32] Debug 2.js.The function don't have a parameter to receive the variable num --- Sprint-2/debug/2.js | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/Sprint-2/debug/2.js b/Sprint-2/debug/2.js index bae9652a8..77b2116df 100644 --- a/Sprint-2/debug/2.js +++ b/Sprint-2/debug/2.js @@ -10,5 +10,41 @@ console.log(`The last digit of 42 is ${getLastDigit(42)}`); console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); -// This program should tell the user the last digit of each number. -// Explain why getLastDigit is not working properly - correct the problem +/* This program should tell the user the last digit of each number. + the function doesn’t have a parameter to receive the num variable it’s trying to process. +// Explain why getLastDigit is not working properly - correct the problem +function getLastDigit() { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + + + +function getLastDigit() { + return num.toString().slice(-1); +}*/ +// FIX + +const num = 103; + +function getLastDigit() { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + +function getLastDigit() { + return num.toString().slice(-1); +} + +gisdellabella@Giss-MBP debug % node 2.js +The last digit of 42 is 3 +The last digit of 105 is 3 +The last digit of 806 is 3 +42 +gisdellabella@Giss-MBP debug % \ No newline at end of file From 6dc1cb6081bd5efd1ba1c52132e09e43c0018122 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 07:44:41 +0000 Subject: [PATCH 04/32] my practice exercise/ explain assert --- Sprint-2/myexc2.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Sprint-2/myexc2.js diff --git a/Sprint-2/myexc2.js b/Sprint-2/myexc2.js new file mode 100644 index 000000000..d2edf12c6 --- /dev/null +++ b/Sprint-2/myexc2.js @@ -0,0 +1,46 @@ +/*function formatAs12HourClock() {} + +const currentOutput = formatAs12HourClock("08:00"); +const targetOutput = "08:00 am"; +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +);*/ + + +/*function formatAs12HourClock(time) { + return `${time} am`; +} + +const currentOutput = formatAs12HourClock("09:00"); +const targetOutput = "09:00 am"; + +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +);*/ + +function formatAs12HourClock(time) { + return `${time} am`; +} + +const currentOutput = formatAs12HourClock("08:00"); +const targetOutput = "08:00 am"; + +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +); + +function formatAs12HourClock(time2) { + return `${time} pm`; +} + +const currentOutput = formatAs12HourClock("23:00"); +const targetOutput = "11:00 pm"; + +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +); + From 5e34bb57c11653344e13057527c154e805c075b6 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 08:20:50 +0000 Subject: [PATCH 05/32] SyntaxError: Identifier 'str' has already been declared/ defined correct the function --- Sprint-2/errors/0.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sprint-2/errors/0.js b/Sprint-2/errors/0.js index 74640e118..9277c64bb 100644 --- a/Sprint-2/errors/0.js +++ b/Sprint-2/errors/0.js @@ -3,7 +3,23 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { +/*function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } + +Error: SyntaxError: Identifier 'str' has already been declared + +Fix:*/ + +function capitalise(capital) { + let str = `${capital.toUpperCase()}${capital.slice(1)}`; + return str; +} + +console.log(`${capitalise(" change this text to uppercase " )}`); + + +/*gisdellabella@Giss-MBP errors % node 0.js + CHANGE THIS TEXT TO UPPERCASE change this text to uppercase +gisdellabella@Giss-MBP errors %*/ \ No newline at end of file From 856a3f5c05afd4dddb10d7ff8ab86dd5491b9d6a Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 19:25:49 +0000 Subject: [PATCH 06/32] Fixed error function name/ 3 is not a valid name --- Sprint-2/errors/2.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-2/errors/2.js b/Sprint-2/errors/2.js index 814334d9e..0852a4a9c 100644 --- a/Sprint-2/errors/2.js +++ b/Sprint-2/errors/2.js @@ -1,10 +1,14 @@ // Predict and explain first... -// this function should square any number but instead we're going to get an error + function square(num) { +return num * num; -function square(3) { - return num * num; -} + } + console.log (square (3)) +/* this function should square any number but instead we're going to get an error + Fix 3 is not valid parameter name. should change function name to square(num) + */ + gisdellabella@Giss-MBP errors % node 2.js From 3cbc91a464dd76312af82ba2aa768b6bbe3368de Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 19:25:59 +0000 Subject: [PATCH 07/32] Fixed Function name error/ 3 is not a valid name --- Sprint-2/debug/0.js | 3 --- Sprint-2/errors/1.js | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/debug/0.js b/Sprint-2/debug/0.js index c931178c1..f0f4e907e 100644 --- a/Sprint-2/debug/0.js +++ b/Sprint-2/debug/0.js @@ -2,9 +2,6 @@ /*it will print the first console.log (a * b) which will call the function inputs 10, 32 = 320 - -Then give a error/ undefined because . - function multiply(a, b) { console.log(a * b); } diff --git a/Sprint-2/errors/1.js b/Sprint-2/errors/1.js index 4602ed237..51a82a915 100644 --- a/Sprint-2/errors/1.js +++ b/Sprint-2/errors/1.js @@ -3,11 +3,14 @@ // Why will an error occur when this program runs? // Try playing computer with the example to work out what is going on + function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; + const decimalNumber = 0.5; + const percentage = `${decimalNumber * 100}%`; return percentage; } console.log(decimalNumber); + +/*ERROR: SyntaxError: Identifier 'decimalNumber' has already been declared \ No newline at end of file From f2a9162660963d7f3ed7b33c99db5d3a47cc8dab Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 20:01:44 +0000 Subject: [PATCH 08/32] Format Time console.assert practice --- Sprint-2/extend/format-time.js | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Sprint-2/extend/format-time.js b/Sprint-2/extend/format-time.js index f3b83062d..5ec03c47b 100644 --- a/Sprint-2/extend/format-time.js +++ b/Sprint-2/extend/format-time.js @@ -22,3 +22,52 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); + +const currentOutput3 = formatAs12HourClock("19:00"); +const targetOutput3 = "7:00 pm"; +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput3}, target output: ${targetOutput3}` +); + + +const currentOutput4 = formatAs12HourClock ("03:00"); +const targetOutput4 = "03:00 am"; +console.assert( + currentOutput4 === targetOutput4, + `current output: ${currentOutput4}, target output: ${targetOutput4}` + ); + + const currentOutput5 = formatAs12HourClock ("01:00"); + + const targetOutput5= "01:00 am"; + + console.assert( + currentOutput5 === targetOutput5, + `curent output: ${currentOutput5}, target output: ${targetOutput5}` + ) + + const currentOutput6 = formatAs12HourClock ("04:00"); + const targetOutput6= "04:00 am"; + console.assert( + currentOutput6 === targetOutput6, + `curent output: ${currentOutput6}, target output: ${targetOutput6}` + ) + + + const currentOutput7 = formatAs12HourClock("22:00") + const targetOutput7 = "10:00 pm"; + + console.assert( + currentOutput7 === targetOutput7, + `curent output: ${currentOutput7}, target output: ${targetOutput7}` + + ) + + const currentOutput9 = formatAs12HourClock("00:00") + const targetOutput9 = "00:00 am"; + console.assert( + currentOutput9 === targetOutput9, + `curent output: ${currentOutput9}, target output: ${targetOutput9}` + + ) \ No newline at end of file From a271680f5a68b40307251822a9901299e5f13e0e Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 20:32:35 +0000 Subject: [PATCH 09/32] Practice Function UpperCase --- Sprint-2/implement/cases.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-2/implement/cases.js b/Sprint-2/implement/cases.js index 9e56a27b6..f3152ae17 100644 --- a/Sprint-2/implement/cases.js +++ b/Sprint-2/implement/cases.js @@ -13,3 +13,15 @@ // You will need to come up with an appropriate name for the function // Use the string documentation to help you find a solution + + +// my fucntion + +function upperSnakeCase(upperCaseTexts) { + return upperCaseTexts.toUpperCase().replace(/\s+/g, '_'); +} + +console.log(`${upperSnakeCase("hello there")}`); + +//gisdellabella@Giss-MBP implement % node cases.js +HELLO_THERE \ No newline at end of file From b06943576d734037db31da6a3c246f2559607727 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 20:34:06 +0000 Subject: [PATCH 10/32] Practicing Function toUpperCase --- Sprint-2/implement/cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/implement/cases.js b/Sprint-2/implement/cases.js index f3152ae17..0395c0f94 100644 --- a/Sprint-2/implement/cases.js +++ b/Sprint-2/implement/cases.js @@ -24,4 +24,4 @@ function upperSnakeCase(upperCaseTexts) { console.log(`${upperSnakeCase("hello there")}`); //gisdellabella@Giss-MBP implement % node cases.js -HELLO_THERE \ No newline at end of file +// HELLO_THERE \ No newline at end of file From 1de6b0fa6e1d5bf64c29ea10216f971377160bec Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Tue, 12 Nov 2024 20:34:33 +0000 Subject: [PATCH 11/32] Applying Function toUpperCase --- Sprint-2/myexc2.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-2/myexc2.js b/Sprint-2/myexc2.js index d2edf12c6..b0d86dd1e 100644 --- a/Sprint-2/myexc2.js +++ b/Sprint-2/myexc2.js @@ -44,3 +44,16 @@ console.assert( `current output: ${currentOutput}, target output: ${targetOutput}` ); + + +//Console assert practice: + +const currentOutput7 = formatAs12HourClock("22:00") + const targetOutput7 = "10:00 pm"; + + console.assert( + currentOutput7 === targetOutput7, + `curent output: ${currentOutput7}, target output: ${targetOutput7}` + + ) + From 2d6c26447af6ed17d7df099cbfc7c35480368227 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Wed, 13 Nov 2024 19:06:21 +0000 Subject: [PATCH 12/32] Code function to add % on a value number --- Sprint-2/implement/vat.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-2/implement/vat.js b/Sprint-2/implement/vat.js index 3fb167226..911da0c8d 100644 --- a/Sprint-2/implement/vat.js +++ b/Sprint-2/implement/vat.js @@ -8,3 +8,13 @@ // Given a number, // When I call this function with a number // it returns the new price with VAT added on + +function addPercentageToPrice(price){ + let vat = (price * 1.2); + return vat; +} + +let price = (20); +console.log(`Product total price is ${addPercentageToPrice(price)}`); + + From 5930178e14264c83f255ace7103eed3f4b1adf39 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Wed, 13 Nov 2024 19:07:27 +0000 Subject: [PATCH 13/32] Function Vat add % to a number --- Sprint-2/MY BMI /index.html | 23 ++++++++++++++++ Sprint-2/MY BMI /script.js | 23 ++++++++++++++++ Sprint-2/MY BMI /style.css | 52 +++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 Sprint-2/MY BMI /index.html create mode 100644 Sprint-2/MY BMI /script.js create mode 100644 Sprint-2/MY BMI /style.css diff --git a/Sprint-2/MY BMI /index.html b/Sprint-2/MY BMI /index.html new file mode 100644 index 000000000..809ace5d2 --- /dev/null +++ b/Sprint-2/MY BMI /index.html @@ -0,0 +1,23 @@ + + + + + + DBMI + + + +
+ Claulate IBM + + + + + + +

Result

+
+ + + + diff --git a/Sprint-2/MY BMI /script.js b/Sprint-2/MY BMI /script.js new file mode 100644 index 000000000..7dfdee365 --- /dev/null +++ b/Sprint-2/MY BMI /script.js @@ -0,0 +1,23 @@ +const weightInput = document.getElementById("weight"); +const heightInput = document.getElementById("height"); +const calculateBtn = document.getElementById("calculate"); +const result = document.getElementById("result"); + +function getBmiStatus(bmi) { if (bmi < 18.5) + { return "Underweight"; } else if (bmi >= 18.5 && bmi < 24.9) + { return "Normal weight"; } else if (bmi >= 24.9 && bmi < 25) + { return "Overweight"; } else if (bmi >= 25 && bmi < 29.9) + { return "Pre-obesity"; } else if (bmi >= 30 && bmi < 34.9) + { return "Obesity - Class I (Moderate)"; } +else if (bmi >= 35 && bmi < 39.9) { return "Obesity - Class II (Severe)"; } +else { return "Obesity - Class III (Very severe or morbidly obese)"; } } + +function calculateBMI() { const weight = parseFloat(weightInput.value); + + const height = parseFloat(heightInput.value); if (weight && height) + + { const heightInMeters = height / 100; const bmi = weight / (heightInMeters * heightInMeters); + const bmiStatus = getBmiStatus(bmi); + result.textContent = `Your BMI: ${bmi.toFixed(1)} + (${bmiStatus})`; } + else { result.textContent = "Please enter valid weight and height values."; } } calculateBtn.addEventListener("click", calculateBMI); \ No newline at end of file diff --git a/Sprint-2/MY BMI /style.css b/Sprint-2/MY BMI /style.css new file mode 100644 index 000000000..558c0c400 --- /dev/null +++ b/Sprint-2/MY BMI /style.css @@ -0,0 +1,52 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background-color: #f0f0f0; +} + +.container { + background-color: #ffffff; + padding: 40px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +h1 { + margin: 0 0 20px; + text-align: center; +} + +.input-container { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 10px; +} + +input { + width: 50%; +} + +button { + display: block; + margin: 20px auto; + padding: 10px 20px; + background-color: #007BFF; + color: #ffffff; + border: none; + border-radius: 5px; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +#result { + text-align: center; + font-weight: bold; +} \ No newline at end of file From bfdb3fb9806f65c854ee31c0c04c997da8c47cff Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Wed, 13 Nov 2024 20:31:45 +0000 Subject: [PATCH 14/32] Add Comments to a line in java Script // --- Sprint-1/errors/0.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/errors/0.js b/Sprint-1/errors/0.js index cf6c5039f..3cd8d38ea 100644 --- a/Sprint-1/errors/0.js +++ b/Sprint-1/errors/0.js @@ -1,2 +1,6 @@ -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? + +// add comets for Line use // +/* comments for many lines +can use */ \ No newline at end of file From 4116ead14e4841d5c3dbe708fafd524da274dcb3 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Thu, 14 Nov 2024 20:27:55 +0000 Subject: [PATCH 15/32] Creating Function BMI --- Sprint-2/implement/bmi.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sprint-2/implement/bmi.js b/Sprint-2/implement/bmi.js index 259f62d48..22e14e381 100644 --- a/Sprint-2/implement/bmi.js +++ b/Sprint-2/implement/bmi.js @@ -13,3 +13,19 @@ // Given someone's weight in kg and height in metres // Then when we call this function with the weight and height // It should return their Body Mass Index to 1 decimal place + + +function ibmCalculator() { + const weight = 53; // Weight in kilograms + const height = 163 / 100; // Convert height from centimeters to meters + + const calculateIBM = weight / Math.pow(height, 2); // Calculate BMI + const result = calculateIBM.toFixed(1); // Format to 1 decimal place + + return result; +} + +console.log(`Your Body Mass Index (BMI) is ${ibmCalculator()}`); + +//gisdellabella@Giss-MBP implement % node bmi.js +//Your Body Mass Index (BMI) is 19.9 From 11078e5ab9d982c534a4cdd0f7b26ac52c4d7323 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Thu, 14 Nov 2024 20:28:01 +0000 Subject: [PATCH 16/32] creating Function bmi --- Sprint-2/implement/bmi.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-2/implement/bmi.js b/Sprint-2/implement/bmi.js index 22e14e381..922e8d7b5 100644 --- a/Sprint-2/implement/bmi.js +++ b/Sprint-2/implement/bmi.js @@ -16,11 +16,11 @@ function ibmCalculator() { - const weight = 53; // Weight in kilograms - const height = 163 / 100; // Convert height from centimeters to meters + const weight = 53; + const height = 163 / 100; //tranforme centimeter to meter - const calculateIBM = weight / Math.pow(height, 2); // Calculate BMI - const result = calculateIBM.toFixed(1); // Format to 1 decimal place + const calculateIBM = weight / Math.pow(height, 2); + const result = calculateIBM.toFixed(1); //chang for decimal return result; } From e8723c01b062282d512db1c2343831a8622d5ca2 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Thu, 14 Nov 2024 22:02:04 +0000 Subject: [PATCH 17/32] code revision --- Sprint-2/implement/bmi.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/bmi.js b/Sprint-2/implement/bmi.js index 922e8d7b5..ccc883b8f 100644 --- a/Sprint-2/implement/bmi.js +++ b/Sprint-2/implement/bmi.js @@ -16,8 +16,8 @@ function ibmCalculator() { - const weight = 53; - const height = 163 / 100; //tranforme centimeter to meter + const weight = 150; + const height = 170 / 100; //tranforme centimeter to meter const calculateIBM = weight / Math.pow(height, 2); const result = calculateIBM.toFixed(1); //chang for decimal @@ -29,3 +29,8 @@ console.log(`Your Body Mass Index (BMI) is ${ibmCalculator()}`); //gisdellabella@Giss-MBP implement % node bmi.js //Your Body Mass Index (BMI) is 19.9 +//Your Body Mass Index (BMI) is 20.7 +//Your Body Mass Index (BMI) is 12.8 +//Your Body Mass Index (BMI) is 51.9 + + From 3e7b8135f686bb9c802d9e1ef48439a3a39de981 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Fri, 15 Nov 2024 08:28:25 +0000 Subject: [PATCH 18/32] Function Time Formatting explained --- Sprint-2/interpret/time-format.js | 53 +++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/Sprint-2/interpret/time-format.js b/Sprint-2/interpret/time-format.js index c5a0c1619..6162b15c8 100644 --- a/Sprint-2/interpret/time-format.js +++ b/Sprint-2/interpret/time-format.js @@ -1,17 +1,16 @@ -function pad(num) { - return num.toString().padStart(2, "0"); +/*function pad(num) { + return num.toString().padStart(2, "0");// convert to a string take 2 caracters if short add "0" to the string } function formatTimeDisplay(seconds) { - const remainingSeconds = seconds % 60; - const totalMinutes = (seconds - remainingSeconds) / 60; - const remainingMinutes = totalMinutes % 60; - const totalHours = (totalMinutes - remainingMinutes) / 60; + //This function converts a time duration (in seconds) into a formatted string in the format "HH:MM:SS" (hours, minutes, seconds). + const remainingSeconds = seconds % 60;// Finds the leftover seconds that don’t make up a full minute. % (modulus operator) returns the remainder when seconds is divided by 60. + const totalMinutes = seconds - remainingSeconds; //Converts the remaining seconds into full minutes by subtracting remainingSeconds and dividing by 60. + const remainingMinutes = totalMinutes % 60; //Converts the remaining seconds into full minutes by subtracting remainingSeconds and dividing by 60. + const totalHours = totalMinutes - remainingMinutes; - return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad( - remainingSeconds - )}`; -} + return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; +} */ // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions @@ -19,13 +18,47 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? +3; // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? +//totalHours = 0 (calculated as (totalMinutes - remainingMinutes) / 60). +//pad is called first with totalHours. +// the value assigned to num is 0. // c) What is the return value of pad is called for the first time? +//The first call to pad receives num = 0. +//Inside pad, 0 is converted to a string: "0". +//.padStart(2, "0") ensures it is at least 2 characters long by adding a leading zero: "00". +//The return value is "00" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer +//The last call to pad is for remainingSeconds, which is 1: +//remainingSeconds = seconds % 60. +//With seconds = 61, remainingSeconds = 61 % 60 = 1. +// the value assigned to num is 1 // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer +//The last call to pad receives num = 1. +//Inside pad, 1 is converted to a string: "1". +//.padStart(2, "0") ensures it is at least 2 characters long by adding a leading zero: "01". +// return value is "01" + +function pad(num) { + return num.toString().padStart(2, "0"); +} + +function formatTimeDisplay(seconds) { + const remainingSeconds = seconds % 60; + const totalMinutes = (seconds - remainingSeconds) / 60; + const remainingMinutes = totalMinutes % 60; + const totalHours = (totalMinutes - remainingMinutes) / 60; + + return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; +} + +console.log(formatTimeDisplay(61)); + +//00:01:01 +//gisdellabella@Giss-MBP interpret % From 1b49ee27e0b787c8d897aeb9a4c8010e71cc372e Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Fri, 15 Nov 2024 08:43:02 +0000 Subject: [PATCH 19/32] Interpreting Time Formatting Function --- Sprint-2/interpret/time-format.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/interpret/time-format.js b/Sprint-2/interpret/time-format.js index 6162b15c8..06dacb2b3 100644 --- a/Sprint-2/interpret/time-format.js +++ b/Sprint-2/interpret/time-format.js @@ -58,7 +58,10 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } -console.log(formatTimeDisplay(61)); - +//console.log(formatTimeDisplay(61)); //00:01:01 //gisdellabella@Giss-MBP interpret % + +console.log(formatTimeDisplay(52)); +00:00:52 +gisdellabella@Giss-MBP interpret % From 32dfaaa254bb9fe2f9069e72d455f8f038f28bfb Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Fri, 15 Nov 2024 08:43:59 +0000 Subject: [PATCH 20/32] Interpreting Function Time formatting --- Sprint-2/MY BMI /index.html | 23 -------------- Sprint-2/MY BMI /script.js | 23 -------------- Sprint-2/MY BMI /style.css | 52 ------------------------------- Sprint-2/implement/to-pounds.js | 54 +++++++++++++++++++++++++++++++++ Sprint-2/implement/vat.js | 3 +- 5 files changed, 55 insertions(+), 100 deletions(-) delete mode 100644 Sprint-2/MY BMI /index.html delete mode 100644 Sprint-2/MY BMI /script.js delete mode 100644 Sprint-2/MY BMI /style.css diff --git a/Sprint-2/MY BMI /index.html b/Sprint-2/MY BMI /index.html deleted file mode 100644 index 809ace5d2..000000000 --- a/Sprint-2/MY BMI /index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - DBMI - - - -
- Claulate IBM - - - - - - -

Result

-
- - - - diff --git a/Sprint-2/MY BMI /script.js b/Sprint-2/MY BMI /script.js deleted file mode 100644 index 7dfdee365..000000000 --- a/Sprint-2/MY BMI /script.js +++ /dev/null @@ -1,23 +0,0 @@ -const weightInput = document.getElementById("weight"); -const heightInput = document.getElementById("height"); -const calculateBtn = document.getElementById("calculate"); -const result = document.getElementById("result"); - -function getBmiStatus(bmi) { if (bmi < 18.5) - { return "Underweight"; } else if (bmi >= 18.5 && bmi < 24.9) - { return "Normal weight"; } else if (bmi >= 24.9 && bmi < 25) - { return "Overweight"; } else if (bmi >= 25 && bmi < 29.9) - { return "Pre-obesity"; } else if (bmi >= 30 && bmi < 34.9) - { return "Obesity - Class I (Moderate)"; } -else if (bmi >= 35 && bmi < 39.9) { return "Obesity - Class II (Severe)"; } -else { return "Obesity - Class III (Very severe or morbidly obese)"; } } - -function calculateBMI() { const weight = parseFloat(weightInput.value); - - const height = parseFloat(heightInput.value); if (weight && height) - - { const heightInMeters = height / 100; const bmi = weight / (heightInMeters * heightInMeters); - const bmiStatus = getBmiStatus(bmi); - result.textContent = `Your BMI: ${bmi.toFixed(1)} - (${bmiStatus})`; } - else { result.textContent = "Please enter valid weight and height values."; } } calculateBtn.addEventListener("click", calculateBMI); \ No newline at end of file diff --git a/Sprint-2/MY BMI /style.css b/Sprint-2/MY BMI /style.css deleted file mode 100644 index 558c0c400..000000000 --- a/Sprint-2/MY BMI /style.css +++ /dev/null @@ -1,52 +0,0 @@ -body { - font-family: Arial, sans-serif; - display: flex; - justify-content: center; - align-items: center; - height: 100vh; - margin: 0; - background-color: #f0f0f0; -} - -.container { - background-color: #ffffff; - padding: 40px; - border-radius: 10px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); -} - -h1 { - margin: 0 0 20px; - text-align: center; -} - -.input-container { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 10px; -} - -input { - width: 50%; -} - -button { - display: block; - margin: 20px auto; - padding: 10px 20px; - background-color: #007BFF; - color: #ffffff; - border: none; - border-radius: 5px; - cursor: pointer; -} - -button:hover { - background-color: #0056b3; -} - -#result { - text-align: center; - font-weight: bold; -} \ No newline at end of file diff --git a/Sprint-2/implement/to-pounds.js b/Sprint-2/implement/to-pounds.js index 6265a1a70..190d1614b 100644 --- a/Sprint-2/implement/to-pounds.js +++ b/Sprint-2/implement/to-pounds.js @@ -4,3 +4,57 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs + +/*function toPounds(penceString) { + const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 + ); + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + + const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 + ); + + const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); +} +const penceString = "399p"; +console.log(`£${pounds}.${pence}`);*/ + +function toPounds(penceString) { + const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 + ); // Remove the "p" + + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); // make sure number string has at least 3 digits + + const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 + ); // Extract pounds and pence + + const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); + + return `£${pounds}.${pence}`; +} // Return the formatted string + +const result1 = toPounds("799p"); +const result2 = toPounds("50p"); +const result3 = toPounds("5230p"); +const result4 = toPounds("545p"); +console.log(result1); +console.log(result2); +console.log(result3); +console.log(result4); + +£7.99 +£0.50 +£52.30 +£5.45 +gisdellabella@Giss-MBP implement % diff --git a/Sprint-2/implement/vat.js b/Sprint-2/implement/vat.js index 911da0c8d..6ea74eca8 100644 --- a/Sprint-2/implement/vat.js +++ b/Sprint-2/implement/vat.js @@ -14,7 +14,6 @@ function addPercentageToPrice(price){ return vat; } -let price = (20); +let price = (30); console.log(`Product total price is ${addPercentageToPrice(price)}`); - From 2bbcf9966b383a2a487a138944dcc2ec21a1bca7 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Fri, 15 Nov 2024 08:49:46 +0000 Subject: [PATCH 21/32] Function to.pound reusable block --- Sprint-2/implement/to-pounds.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/to-pounds.js b/Sprint-2/implement/to-pounds.js index 190d1614b..96a2282c5 100644 --- a/Sprint-2/implement/to-pounds.js +++ b/Sprint-2/implement/to-pounds.js @@ -53,8 +53,8 @@ console.log(result2); console.log(result3); console.log(result4); +gisdellabella@Giss-MBP implement % node to-pounds.js £7.99 £0.50 £52.30 -£5.45 -gisdellabella@Giss-MBP implement % +£5.45 \ No newline at end of file From 7ce5b80a78bd41dfa576c14e33ad4c8ab84e0eac Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Fri, 15 Nov 2024 08:55:22 +0000 Subject: [PATCH 22/32] Revising function % vat --- Sprint-2/implement/vat.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Sprint-2/implement/vat.js b/Sprint-2/implement/vat.js index 6ea74eca8..1eec2cde2 100644 --- a/Sprint-2/implement/vat.js +++ b/Sprint-2/implement/vat.js @@ -9,11 +9,14 @@ // When I call this function with a number // it returns the new price with VAT added on -function addPercentageToPrice(price){ - let vat = (price * 1.2); - return vat; +function addPercentageToPrice(price) { + let vat = price * 1.2; + return vat; } - -let price = (30); + +let price = 675; console.log(`Product total price is ${addPercentageToPrice(price)}`); +//let price = 30; Product total price is 36 +//let price = 45; Product total price is 54 +//let price = 45; Product total price is 810 From 6f78ed91a86c58d2682fc4270bc280b89ac74d82 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 11:54:22 +0000 Subject: [PATCH 23/32] Debugging the error --- Sprint-2/debug/0.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-2/debug/0.js b/Sprint-2/debug/0.js index f0f4e907e..58dadd2d6 100644 --- a/Sprint-2/debug/0.js +++ b/Sprint-2/debug/0.js @@ -18,5 +18,15 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +// The function wasn't called initially, so it didn't display the result. +// //However, it has now been called and is returning the result. + + + + + + + + From 661fd6d1f47b84ad1a2f41f56be3f615781a7ed3 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 12:14:33 +0000 Subject: [PATCH 24/32] Fixing function returning the Sum --- Sprint-2/debug/1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/debug/1.js b/Sprint-2/debug/1.js index 25f24579e..781703359 100644 --- a/Sprint-2/debug/1.js +++ b/Sprint-2/debug/1.js @@ -14,8 +14,11 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);*/ //FIX:// function sum(a, b) { - return; a + b; + return a + b; } console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +//The result wasn't returned because the sum of a and b wasn't included. + + From 17f8b03cbe6b498ad0f40423e1e778282b4ee7b8 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 12:42:39 +0000 Subject: [PATCH 25/32] Fix it --- Sprint-2/debug/1.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/debug/1.js b/Sprint-2/debug/1.js index 781703359..043381039 100644 --- a/Sprint-2/debug/1.js +++ b/Sprint-2/debug/1.js @@ -20,5 +20,4 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); //The result wasn't returned because the sum of a and b wasn't included. - - +//Now I have fixed the code, and it is returning the result From 9b2ceee41e9ae2f9f1419c4887b83435f664f4a9 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 12:43:58 +0000 Subject: [PATCH 26/32] Declared the function --- Sprint-2/debug/2.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/debug/2.js b/Sprint-2/debug/2.js index 77b2116df..54ca44edc 100644 --- a/Sprint-2/debug/2.js +++ b/Sprint-2/debug/2.js @@ -1,9 +1,9 @@ // Predict and explain first... -const num = 103; +//const num = 103; -function getLastDigit() { - return num.toString().slice(-1); +function getLastDigit(numLast) { + return numLast.toString().slice(-1); } console.log(`The last digit of 42 is ${getLastDigit(42)}`); @@ -28,7 +28,7 @@ function getLastDigit() { }*/ // FIX -const num = 103; +/*const num = 103; function getLastDigit() { return num.toString().slice(-1); @@ -47,4 +47,4 @@ The last digit of 42 is 3 The last digit of 105 is 3 The last digit of 806 is 3 42 -gisdellabella@Giss-MBP debug % \ No newline at end of file +gisdellabella@Giss-MBP debug */ \ No newline at end of file From 17d1618436ef72fbdd53e66334675b2dfb7fe2ce Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 12:44:48 +0000 Subject: [PATCH 27/32] Removed the duplicated declaration --- Sprint-2/errors/1.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-2/errors/1.js b/Sprint-2/errors/1.js index 51a82a915..18a9a8372 100644 --- a/Sprint-2/errors/1.js +++ b/Sprint-2/errors/1.js @@ -5,12 +5,14 @@ function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; + + const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(0.5); + +// const decimalNumber = 0.5; +// ERROR: SyntaxError: Identifier 'decimalNumber' has already been declared -/*ERROR: SyntaxError: Identifier 'decimalNumber' has already been declared \ No newline at end of file From f519e88eb8e347943700180cade09132d9fddfb3 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 15:02:01 +0000 Subject: [PATCH 28/32] Fixing changing the name of the function. --- Sprint-2/errors/2.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sprint-2/errors/2.js b/Sprint-2/errors/2.js index 0852a4a9c..2742fd7d4 100644 --- a/Sprint-2/errors/2.js +++ b/Sprint-2/errors/2.js @@ -8,7 +8,6 @@ return num * num; console.log (square (3)) -/* this function should square any number but instead we're going to get an error - Fix 3 is not valid parameter name. should change function name to square(num) - */ - gisdellabella@Giss-MBP errors % node 2.js + +//The error was with parameter 3, which always gave me the same result. +// By changing it to "num," the function now works with any number. Also 3 is used as the parameter name for the function, which is not valid in JavaScript. From 8631aae8e1c153979f5050debd0568165b44af08 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 15:22:09 +0000 Subject: [PATCH 29/32] Fix the units/ removed the constant values --- Sprint-2/implement/bmi.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Sprint-2/implement/bmi.js b/Sprint-2/implement/bmi.js index ccc883b8f..28488fee0 100644 --- a/Sprint-2/implement/bmi.js +++ b/Sprint-2/implement/bmi.js @@ -15,22 +15,19 @@ // It should return their Body Mass Index to 1 decimal place -function ibmCalculator() { - const weight = 150; - const height = 170 / 100; //tranforme centimeter to meter +// const weight = 150; +// const height = 170 / 100; //tranforme centimeter to meter - const calculateIBM = weight / Math.pow(height, 2); - const result = calculateIBM.toFixed(1); //chang for decimal +function ibmCalculator( weight, height) { + + height = height / 100; + let calculateIBM = weight / Math.pow(height, 2); + let result = calculateIBM.toFixed(1); //chang for decimal return result; } -console.log(`Your Body Mass Index (BMI) is ${ibmCalculator()}`); -//gisdellabella@Giss-MBP implement % node bmi.js -//Your Body Mass Index (BMI) is 19.9 -//Your Body Mass Index (BMI) is 20.7 -//Your Body Mass Index (BMI) is 12.8 -//Your Body Mass Index (BMI) is 51.9 +console.log(`Your Body Mass Index (BMI) is ${ibmCalculator(98,126)}`); From d4486d694c3b53efdeaae1dcdaa1aed8ef949237 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 15:53:30 +0000 Subject: [PATCH 30/32] Fix the function convert numbers to 12 hours format --- Sprint-2/interpret/myexc2.js | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Sprint-2/interpret/myexc2.js diff --git a/Sprint-2/interpret/myexc2.js b/Sprint-2/interpret/myexc2.js new file mode 100644 index 000000000..e0735b3b6 --- /dev/null +++ b/Sprint-2/interpret/myexc2.js @@ -0,0 +1,50 @@ +/*function formatAs12HourClock() {} + +const currentOutput = formatAs12HourClock("08:00"); +const targetOutput = "08:00 am"; +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +);*/ + + +/*function formatAs12HourClock(time) { + return `${time} am`; +} + +const currentOutput = formatAs12HourClock("09:00"); +const targetOutput = "09:00 am"; + +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +);*/ + +function formatAs12HourClock(time) { + //time format hh:mm in 24h time + + let hours = time[0] + time[1]; + let mint = time[3] + time[4]; // not count the colon + hours = parseInt(hours); + hours = hours % 12; + hours = hours.toString(); + return hours + ":" + mint ; + + +} + +console.log(formatAs12HourClock("15:34")) + + + +//Console assert practice: + +// const currentOutput7 = formatAs12HourClock("22:00") +// const targetOutput7 = "10:00 pm"; + +// console.assert( +// currentOutput7 === targetOutput7, +// `curent output: ${currentOutput7}, target output: ${targetOutput7}` + +// ) + From 616ef23156e03284c28baab0849c8da0d791da68 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 16:05:12 +0000 Subject: [PATCH 31/32] shor wat to implemeting ++1 = count++; --- Sprint-1/exercises/count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/exercises/count.js b/Sprint-1/exercises/count.js index 117bcb2b6..b263803f0 100644 --- a/Sprint-1/exercises/count.js +++ b/Sprint-1/exercises/count.js @@ -1,6 +1,6 @@ let count = 0; -count = count + 1; +count = 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 From a8316b9996bf821e39b8c3af46156dd129192101 Mon Sep 17 00:00:00 2001 From: Della-Bella Date: Sat, 21 Dec 2024 16:05:43 +0000 Subject: [PATCH 32/32] Fix the count++; --- Sprint-1/exercises/count.js | 2 +- Sprint-2/myexc2.js | 59 ------------------------------------- 2 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 Sprint-2/myexc2.js diff --git a/Sprint-1/exercises/count.js b/Sprint-1/exercises/count.js index b263803f0..d71b8f1c3 100644 --- a/Sprint-1/exercises/count.js +++ b/Sprint-1/exercises/count.js @@ -1,6 +1,6 @@ let count = 0; -count = count++;; +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-2/myexc2.js b/Sprint-2/myexc2.js deleted file mode 100644 index b0d86dd1e..000000000 --- a/Sprint-2/myexc2.js +++ /dev/null @@ -1,59 +0,0 @@ -/*function formatAs12HourClock() {} - -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -);*/ - - -/*function formatAs12HourClock(time) { - return `${time} am`; -} - -const currentOutput = formatAs12HourClock("09:00"); -const targetOutput = "09:00 am"; - -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -);*/ - -function formatAs12HourClock(time) { - return `${time} am`; -} - -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; - -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); - -function formatAs12HourClock(time2) { - return `${time} pm`; -} - -const currentOutput = formatAs12HourClock("23:00"); -const targetOutput = "11:00 pm"; - -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); - - - -//Console assert practice: - -const currentOutput7 = formatAs12HourClock("22:00") - const targetOutput7 = "10:00 pm"; - - console.assert( - currentOutput7 === targetOutput7, - `curent output: ${currentOutput7}, target output: ${targetOutput7}` - - ) -