From d0f5f37d5c81d0695cbccff9f063cd6b341bf7d2 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:11:41 +0100 Subject: [PATCH 01/93] Implemented case 2: Identify Acute Angles for getAngleType in 1-get-angle-type.js in ket implement sprint 3. --- Sprint-3/1-key-implement/1-get-angle-type.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 08d1f0cbaf..c8002e97a7 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -8,8 +8,12 @@ // Then, write the next test! :) Go through this process until all the cases are implemented function getAngleType(angle) { - if (angle === 90) return "Right angle"; - // read to the end, complete line 36, then pass your test here + if (angle === 90) { + return "Right angle"; + } + if (angle < 90) { + return "Acute angle"; + } } // we're going to use this helper function to make our assertions easier to read From 099d53ae0c99fa07ffe6560002170dcbbd6f3b50 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:15:16 +0100 Subject: [PATCH 02/93] Added test for case 3: Identify Obtuse Angel 1-get-angle-type.js in key sprint 3 implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index c8002e97a7..8764875a9c 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -48,6 +48,7 @@ assertEquals(acute, "Acute angle"); // Then the function should return "Obtuse angle" const obtuse = getAngleType(120); // ====> write your test here, and then add a line to pass the test in the function above +assertEquals(acute, "Obtuse angel") // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, From cb211f775cfdcff26e89d2518152a7968897ea8b Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:21:06 +0100 Subject: [PATCH 03/93] Update test for case 3: Identify obtuse angle in 1-get-angle-type.js for sprint 3 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 8764875a9c..b576c77692 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -48,7 +48,7 @@ assertEquals(acute, "Acute angle"); // Then the function should return "Obtuse angle" const obtuse = getAngleType(120); // ====> write your test here, and then add a line to pass the test in the function above -assertEquals(acute, "Obtuse angel") +assertEquals(obtuse, "Obtuse angle") // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, From 398f3817c25c7f2eba8886c1ca83462b14128cad Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:26:00 +0100 Subject: [PATCH 04/93] Implemeted the function behaviour for case 3: Identify Obtuse Angle for 1-get-angel-type.js in sprint 3 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index b576c77692..1b5113e53c 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -13,7 +13,10 @@ function getAngleType(angle) { } if (angle < 90) { return "Acute angle"; - } + } + if (angle < 180) { + return "Obtuse angle"; + } } // we're going to use this helper function to make our assertions easier to read From 7116b75f46ec4d751c756d55d4ee11c1bcae1534 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:46:46 +0100 Subject: [PATCH 05/93] Added case 4: Identify Straight Angles test in 1-get-angle-type.js for sprint 3 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 1b5113e53c..77475b405c 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -51,12 +51,14 @@ assertEquals(acute, "Acute angle"); // Then the function should return "Obtuse angle" const obtuse = getAngleType(120); // ====> write your test here, and then add a line to pass the test in the function above -assertEquals(obtuse, "Obtuse angle") +assertEquals(obtuse, "Obtuse angle"); // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, // Then the function should return "Straight angle" // ====> write your test here, and then add a line to pass the test in the function above +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, From e3590e3587998f602f432adc25d31cc176cf80a7 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:53:25 +0100 Subject: [PATCH 06/93] Implemented function logic for case 4: Identify Stright Angle in 1-get-angle-type.js sprint 3 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index 77475b405c..fc9d5baeba 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -11,6 +11,9 @@ function getAngleType(angle) { if (angle === 90) { return "Right angle"; } + if (angle === 180) { + return "Straight angle"; + } if (angle < 90) { return "Acute angle"; } From 5d71909f6d5ca521808ef03dea20c2b6cc472a89 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 11:59:52 +0100 Subject: [PATCH 07/93] Added test for case 5: Identify reflex Angles in 1-get-angle-type.js sprint 2 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index fc9d5baeba..efa5f2ab43 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -66,4 +66,6 @@ assertEquals(straight, "Straight angle"); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" -// ====> write your test here, and then add a line to pass the test in the function above \ No newline at end of file +// ====> write your test here, and then add a line to pass the test in the function above +const reflex = getAngleType(210); +assertEquals(reflex, "Reflex angle"); \ No newline at end of file From dc7b8bf285837b4e0c3a8d9d8c825bb261d454a1 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 12:01:47 +0100 Subject: [PATCH 08/93] Implemented function logic for case 5: Identify Reflex Angle 1-get-angle-type.js sprint 2 key implement part. --- Sprint-3/1-key-implement/1-get-angle-type.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/1-key-implement/1-get-angle-type.js b/Sprint-3/1-key-implement/1-get-angle-type.js index efa5f2ab43..062d43e019 100644 --- a/Sprint-3/1-key-implement/1-get-angle-type.js +++ b/Sprint-3/1-key-implement/1-get-angle-type.js @@ -20,6 +20,9 @@ function getAngleType(angle) { if (angle < 180) { return "Obtuse angle"; } + if (angle < 360) { + return "Reflex angle"; + } } // we're going to use this helper function to make our assertions easier to read From 194539cb079b3ca39664716f609e47ada2d75d22 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 22:14:37 +0100 Subject: [PATCH 09/93] Implemented the function logic for Improper Fraction check in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 91583e9413..82cf8505da 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -8,7 +8,11 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (numerator < denominator) return true; + if (numerator < denominator) { + return true; + } else { + return false; + } } // here's our helper again From b66cecb3439af6864e88494119327643fb17a478 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 22:16:53 +0100 Subject: [PATCH 10/93] Added the assertion for Negative fraction check in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 82cf8505da..dd0b0dd8ff 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -45,6 +45,7 @@ assertEquals(improperFraction, false); // Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true. const negativeFraction = isProperFraction(-4, 7); // ====> complete with your assertion +assertEquals(negativeFraction, true); // Equal Numerator and Denominator check: // Input: numerator = 3, denominator = 3 From 626ac9e61aed1ec14630e797bca18bd11c4369dc Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 22:19:46 +0100 Subject: [PATCH 11/93] Added the assertion for Equal numerator and denominator chack in 2-is-proper-fraction.js sprint 2 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index dd0b0dd8ff..73cb34d8ff 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -53,6 +53,7 @@ assertEquals(negativeFraction, true); // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. const equalFraction = isProperFraction(3, 3); // ====> complete with your assertion +assertEquals(equalFraction, false); // Stretch: // What other scenarios could you test for? From b6729fad22b5f44d3f0d257887f849611c4bdc64 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 22:35:54 +0100 Subject: [PATCH 12/93] Added assertion for Negative numerator with absolute value greater than denominator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 73cb34d8ff..8d5f75b4e0 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -57,3 +57,10 @@ assertEquals(equalFraction, false); // Stretch: // What other scenarios could you test for? + +// Negative numerator with absolute value greater than denominator +// Input numerator = -5 denominator = 2 +// Target output: false +// Explanation: The fraction -5/2 is a improper fraction because the absolute value of the numerator (-5) is greater than the denominator (2). The function should return false. +const negativeGreaterNumerator = isProperFraction(-5, 2); +assertEquals(negativeGreaterNumerator, false); \ No newline at end of file From 96cd56895f33e6d3a14d367af1b4575234f2b939 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 22:39:48 +0100 Subject: [PATCH 13/93] Implemets the function logic for case Negative numerator with absolute value greater than denominator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 8d5f75b4e0..7a22ad04ed 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -8,7 +8,7 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (numerator < denominator) { + if (Math.abs(numerator) < denominator) { return true; } else { return false; From 42a299c1e313cbb53f82ac9ba3283106e28d21bc Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:06:00 +0100 Subject: [PATCH 14/93] Added assertion for case of the negative denominator with the absolute value greater than numerator in 2-is-propr-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 7a22ad04ed..72d0c8cd28 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -63,4 +63,11 @@ assertEquals(equalFraction, false); // Target output: false // Explanation: The fraction -5/2 is a improper fraction because the absolute value of the numerator (-5) is greater than the denominator (2). The function should return false. const negativeGreaterNumerator = isProperFraction(-5, 2); -assertEquals(negativeGreaterNumerator, false); \ No newline at end of file +assertEquals(negativeGreaterNumerator, false); + +// Negative denominator with absolute value greater than numerator +// Input numerator = 2 denominator = -5 +// Target output: true +// Explanation: The fraction 2/-5 is a proper fraction because the numerator (2) is greater than the absolute value of the denominator (-5). The function should return true. +const negativeGreaterDenominator = isProperFraction(2, -5); +assertEquals(negativeGreaterDenominator, true); \ No newline at end of file From d08fc1e1cd52eadd5914b2a49975106a3d4dcbfe Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:09:44 +0100 Subject: [PATCH 15/93] Implemented the function logic for case of the negative denominator with the absolute value greater than numerator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 72d0c8cd28..2170aaac16 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -8,7 +8,7 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (Math.abs(numerator) < denominator) { + if (Math.abs(numerator) < Math.abs(denominator)) { return true; } else { return false; From e0874e7377cca29e4c239147a90dae45e0671139 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:13:54 +0100 Subject: [PATCH 16/93] Added the assertion for the case of negative denominator with absolute value less than numerator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 2170aaac16..2ef048afa1 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -70,4 +70,11 @@ assertEquals(negativeGreaterNumerator, false); // Target output: true // Explanation: The fraction 2/-5 is a proper fraction because the numerator (2) is greater than the absolute value of the denominator (-5). The function should return true. const negativeGreaterDenominator = isProperFraction(2, -5); -assertEquals(negativeGreaterDenominator, true); \ No newline at end of file +assertEquals(negativeGreaterDenominator, true); + +// Negative denominator with absolute value less than numerator +// Input numerator = 5 denominator = -2 +// Target output: false +// Explanation: The fraction 5/-2 is a improper fraction because the numerator (5) is greater than the absolute value of the denominator (-2). The function should return true. +const negativeLessDenominator = isProperFraction(5, -2); +assertEquals(negativeLessDenominator, false); \ No newline at end of file From d0d6bcf30040cbf7891148b7eead8a8b86e16d3d Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:26:50 +0100 Subject: [PATCH 17/93] Added the assertion for the case then both values negative and numerator is less in absolute values in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 2ef048afa1..16764da78b 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -59,22 +59,29 @@ assertEquals(equalFraction, false); // What other scenarios could you test for? // Negative numerator with absolute value greater than denominator -// Input numerator = -5 denominator = 2 +// Input: numerator = -5 denominator = 2 // Target output: false // Explanation: The fraction -5/2 is a improper fraction because the absolute value of the numerator (-5) is greater than the denominator (2). The function should return false. const negativeGreaterNumerator = isProperFraction(-5, 2); assertEquals(negativeGreaterNumerator, false); // Negative denominator with absolute value greater than numerator -// Input numerator = 2 denominator = -5 +// Input: numerator = 2 denominator = -5 // Target output: true // Explanation: The fraction 2/-5 is a proper fraction because the numerator (2) is greater than the absolute value of the denominator (-5). The function should return true. const negativeGreaterDenominator = isProperFraction(2, -5); assertEquals(negativeGreaterDenominator, true); // Negative denominator with absolute value less than numerator -// Input numerator = 5 denominator = -2 +// Input: numerator = 5 denominator = -2 // Target output: false // Explanation: The fraction 5/-2 is a improper fraction because the numerator (5) is greater than the absolute value of the denominator (-2). The function should return true. const negativeLessDenominator = isProperFraction(5, -2); -assertEquals(negativeLessDenominator, false); \ No newline at end of file +assertEquals(negativeLessDenominator, false); + +// Both negative with numerator less in absolute value +// Input: numerator = -2 denominator = -5 +// Target output: true +// Explanation: the fraction -2/-2 is a proper fraction because the absolute value of the numerator less than the absolute value of the denominator. +const bothNegativeNumeratorLess = isProperFraction(-2, -5); +assertEquals(bothNegativeNumeratorLess, true); \ No newline at end of file From 7ee33b3c7b69fdb80a9ded2b1fcad74f75c61207 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:31:24 +0100 Subject: [PATCH 18/93] Added the asertion for the case wen both parts are negative and the numerator value is greater in absolute values in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 16764da78b..d199945db9 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -82,6 +82,13 @@ assertEquals(negativeLessDenominator, false); // Both negative with numerator less in absolute value // Input: numerator = -2 denominator = -5 // Target output: true -// Explanation: the fraction -2/-2 is a proper fraction because the absolute value of the numerator less than the absolute value of the denominator. +// Explanation: the fraction -2/-5 is a proper fraction because the absolute value of the numerator (-2) less than the absolute value of the denominator (-5). const bothNegativeNumeratorLess = isProperFraction(-2, -5); -assertEquals(bothNegativeNumeratorLess, true); \ No newline at end of file +assertEquals(bothNegativeNumeratorLess, true); + +// Both negative with numerator greater in absolute value +// Input: numerator = -5 denominator = -2 +// Target output: false +// Explanation: the fraction -5/-2 is a improper fraction because the absolute value of the numerator(-5) greater than the absolute value of the denominator (-2). +const bothNegativeNumeratorGreater = isProperFraction(-5, -2); +assertEquals(bothNegativeNumeratorGreater, false); \ No newline at end of file From 999a10fa3e9ba942fb07a0e386ea0aa4c392853f Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Tue, 16 Dec 2025 23:57:25 +0100 Subject: [PATCH 19/93] Added the assertion for the case with equal negative numerator and denominator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index d199945db9..e5e1b03800 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -91,4 +91,11 @@ assertEquals(bothNegativeNumeratorLess, true); // Target output: false // Explanation: the fraction -5/-2 is a improper fraction because the absolute value of the numerator(-5) greater than the absolute value of the denominator (-2). const bothNegativeNumeratorGreater = isProperFraction(-5, -2); -assertEquals(bothNegativeNumeratorGreater, false); \ No newline at end of file +assertEquals(bothNegativeNumeratorGreater, false); + +// Both negative with equal values +// Input: numerator = -2 denominator = -2 +// Target output: false +// Explanation: the fraction -2/-2 is a improper fraction because the numerator(-2) equal to the the denominator (-2). +const bothNegativeEqual = isProperFraction(-2, -2); +assertEquals(bothNegativeEqual, false); \ No newline at end of file From dbe15de42014b8a181ea357c7d2aa1728da7b3d5 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 00:03:46 +0100 Subject: [PATCH 20/93] Added the assertion for the case of zero numerator in 2-is-proper-frcation.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index e5e1b03800..c38278de44 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -98,4 +98,11 @@ assertEquals(bothNegativeNumeratorGreater, false); // Target output: false // Explanation: the fraction -2/-2 is a improper fraction because the numerator(-2) equal to the the denominator (-2). const bothNegativeEqual = isProperFraction(-2, -2); -assertEquals(bothNegativeEqual, false); \ No newline at end of file +assertEquals(bothNegativeEqual, false); + +// Numerator is zero +// Input: numerator = 0 denominator = 2 +// Target output: true +// Explanation: the fraction 0/2 is a proper fraction because the numerator (0) less than the absolute value of the denominator. +const zeroNumerator = isProperFraction(0, 2); +assertEquals(zeroNumerator, true); \ No newline at end of file From 19522b3d898b51d45611f8ee24b24932bf7d1ed7 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 00:06:35 +0100 Subject: [PATCH 21/93] Added the assertion for the case of zero denominator in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index c38278de44..7d2fe6175f 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -103,6 +103,13 @@ assertEquals(bothNegativeEqual, false); // Numerator is zero // Input: numerator = 0 denominator = 2 // Target output: true -// Explanation: the fraction 0/2 is a proper fraction because the numerator (0) less than the absolute value of the denominator. +// Explanation: the fraction 0/2 is a proper fraction because the numerator (0) less than the absolute value of the denominator (2). const zeroNumerator = isProperFraction(0, 2); -assertEquals(zeroNumerator, true); \ No newline at end of file +assertEquals(zeroNumerator, true); + +// Denominator is zero +// Input: numerator = 2 denominator = 0 +// Target output: false +// Explanation: the fraction 2/0 is a improper fraction because the absolute value of the numerator (2) greater than the denominator (0). +const zeroDenominator = isProperFraction(0, 2); +assertEquals(zeroDenominator, true); \ No newline at end of file From bb25404eb9f801ca1555521273bf2773abb82ebc Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 00:09:35 +0100 Subject: [PATCH 22/93] Update the function logic in 2-is-proper-fraction.js sprint 3 key implement part. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 7d2fe6175f..0e67f73db8 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -8,11 +8,7 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (Math.abs(numerator) < Math.abs(denominator)) { - return true; - } else { - return false; - } + return Math.abs(numerator / denominator) < 1; } // here's our helper again From 5c84687f909399e5b6d3afc140c8c9107e6f7878 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:01:40 +0100 Subject: [PATCH 23/93] Implemented --- Sprint-3/1-key-implement/3-get-card-value.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index aa1cc9f90b..c529eaaa61 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -8,7 +8,11 @@ // write one test at a time, and make it pass, build your solution up methodically // just make one change at a time -- don't rush -- programmers are deep and careful thinkers function getCardValue(card) { - if (rank === "A") return 11; + const rank = card.slice(0, card.length - 1); + switch (rank) { + case "A": + return 11; + } } // You need to write assertions for your function to check it works in different cases From e6d27dfec4d6db973553e58cc46f75af8f92184b Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:07:10 +0100 Subject: [PATCH 24/93] Implemented determination the rank of card logic. Implemented calculating the return value for the aces case. --- Sprint-3/1-key-implement/3-get-card-value.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index aa1cc9f90b..bd34c9750a 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -8,7 +8,11 @@ // write one test at a time, and make it pass, build your solution up methodically // just make one change at a time -- don't rush -- programmers are deep and careful thinkers function getCardValue(card) { - if (rank === "A") return 11; + const rank = card.slice(0, card.length - 1); + switch (rank) { + case "A": + return 11; + } } // You need to write assertions for your function to check it works in different cases @@ -25,8 +29,8 @@ function assertEquals(actualOutput, targetOutput) { // Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A), // When the function getCardValue is called with this card string as input, // Then it should return the numerical card value -const aceofSpades = getCardValue("A♠"); -assertEquals(aceofSpades, 11); +const aceOfSpades = getCardValue("A♠"); +assertEquals(aceOfSpades, 11); // Handle Number Cards (2-10): // Given a card with a rank between "2" and "9", From 2e04439f69f470fcab9a15c7d7658f04886e050a Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:12:34 +0100 Subject: [PATCH 25/93] Added the assertion for the number cards case. --- Sprint-3/1-key-implement/3-get-card-value.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index bd34c9750a..59eeed3de0 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -36,8 +36,9 @@ assertEquals(aceOfSpades, 11); // Given a card with a rank between "2" and "9", // When the function is called with such a card, // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). -const fiveofHearts = getCardValue("5♥"); +const fiveOfHearts = getCardValue("5♥"); // ====> write your test here, and then add a line to pass the test in the function above +assertEquals(fiveOfHearts, 5); // Handle Face Cards (J, Q, K): // Given a card with a rank of "10," "J," "Q," or "K", From 8dee5b409927d098295eee30228da1a7233dddda Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:21:12 +0100 Subject: [PATCH 26/93] Implemented logic for handling Number cards. Added assertions for missing number card ranks. --- Sprint-3/1-key-implement/3-get-card-value.js | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index 59eeed3de0..aec87442b8 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -12,6 +12,15 @@ function getCardValue(card) { switch (rank) { case "A": return 11; + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + case "9": + return Number(rank); } } @@ -37,8 +46,22 @@ assertEquals(aceOfSpades, 11); // When the function is called with such a card, // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). const fiveOfHearts = getCardValue("5♥"); +const twoOfHearts = getCardValue("2♥"); +const threeOfHearts = getCardValue("3♥"); +const fourOfHearts = getCardValue("4♥"); +const sixOfHearts = getCardValue("6♥"); +const sevenOfHearts = getCardValue("7♥"); +const eightOfHearts = getCardValue("8♥"); +const nineOfHearts = getCardValue("9♥"); // ====> write your test here, and then add a line to pass the test in the function above assertEquals(fiveOfHearts, 5); +assertEquals(twoOfHearts, 2); +assertEquals(threeOfHearts, 3); +assertEquals(fourOfHearts, 4); +assertEquals(sixOfHearts, 6); +assertEquals(sevenOfHearts, 7); +assertEquals(eightOfHearts, 8); +assertEquals(nineOfHearts, 9); // Handle Face Cards (J, Q, K): // Given a card with a rank of "10," "J," "Q," or "K", From 71a2225392fbd51e8f129098e7330f25d6b196c8 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:32:51 +0100 Subject: [PATCH 27/93] Added assertion for Face card cases to handle tens, jacks, queens, kings. --- Sprint-3/1-key-implement/3-get-card-value.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index aec87442b8..6288cc1b9c 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -67,6 +67,14 @@ assertEquals(nineOfHearts, 9); // Given a card with a rank of "10," "J," "Q," or "K", // When the function is called with such a card, // Then it should return the value 10, as these cards are worth 10 points each in blackjack. +const tenOfClubs = "10♣"; +const jackOfClubs = "J♣"; +const queenOfClubs = "Q♣"; +const kingOfClubs = "K♣"; +assertEquals(tenOfClubs, 10); +assertEquals(jackOfClubs, 10); +assertEquals(queenOfClubs, 10); +assertEquals(kingOfClubs, 10); // Handle Ace (A): // Given a card with a rank of "A", From 1b5420aaa9a0a2b96c7965882b86622d6a4fac3a Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:39:58 +0100 Subject: [PATCH 28/93] Fixed assertions for Face cards, added function call for cards strings. --- Sprint-3/1-key-implement/3-get-card-value.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index 6288cc1b9c..70d66f7b4f 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -67,10 +67,10 @@ assertEquals(nineOfHearts, 9); // Given a card with a rank of "10," "J," "Q," or "K", // When the function is called with such a card, // Then it should return the value 10, as these cards are worth 10 points each in blackjack. -const tenOfClubs = "10♣"; -const jackOfClubs = "J♣"; -const queenOfClubs = "Q♣"; -const kingOfClubs = "K♣"; +const tenOfClubs = getCardValue("10♣"); +const jackOfClubs = getCardValue("J♣"); +const queenOfClubs = getCardValue("Q♣"); +const kingOfClubs = getCardValue("K♣"); assertEquals(tenOfClubs, 10); assertEquals(jackOfClubs, 10); assertEquals(queenOfClubs, 10); From 41d33ea6f6477f0d8af968e54b0a0cbb60bfb443 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:41:51 +0100 Subject: [PATCH 29/93] Implemented function logic for handle Face cards. --- Sprint-3/1-key-implement/3-get-card-value.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index 70d66f7b4f..91b0669a0d 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -21,6 +21,11 @@ function getCardValue(card) { case "8": case "9": return Number(rank); + case "10": + case "J": + case "Q": + case "K": + return 10; } } From aa993300bfb5a35f699a6b805c633b8b5f4d68f1 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 11:53:43 +0100 Subject: [PATCH 30/93] Moved the Ace case assertion and logic code for consistently reasons. --- Sprint-3/1-key-implement/3-get-card-value.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index 91b0669a0d..ea5874a470 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -10,8 +10,6 @@ function getCardValue(card) { const rank = card.slice(0, card.length - 1); switch (rank) { - case "A": - return 11; case "2": case "3": case "4": @@ -26,6 +24,8 @@ function getCardValue(card) { case "Q": case "K": return 10; + case "A": + return 11; } } @@ -43,8 +43,6 @@ function assertEquals(actualOutput, targetOutput) { // Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A), // When the function getCardValue is called with this card string as input, // Then it should return the numerical card value -const aceOfSpades = getCardValue("A♠"); -assertEquals(aceOfSpades, 11); // Handle Number Cards (2-10): // Given a card with a rank between "2" and "9", @@ -85,6 +83,8 @@ assertEquals(kingOfClubs, 10); // Given a card with a rank of "A", // When the function is called with an Ace, // Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack. +const aceOfSpades = getCardValue("A♠"); +assertEquals(aceOfSpades, 11); // Handle Invalid Cards: // Given a card with an invalid rank (neither a number nor a recognized face card), From 281bcaa0052fa321e17e8afba93350bea6f36694 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 12:04:41 +0100 Subject: [PATCH 31/93] Added function calling for invalid cards. --- Sprint-3/1-key-implement/3-get-card-value.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index ea5874a470..d40201f951 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -90,3 +90,13 @@ assertEquals(aceOfSpades, 11); // Given a card with an invalid rank (neither a number nor a recognized face card), // When the function is called with such a card, // Then it should throw an error indicating "Invalid card rank." + +const oneOfDiamonds = "1♦"; +const twentyUnoOfDiamonds = "21♦"; +const hundredOfDiamonds = "100♦"; +const catOfDiamonds = "C♦"; + +getCardValue(oneOfDiamonds); +getCardValue(twentyUnoOfDiamonds); +getCardValue(hundredOfDiamonds); +getCardValue(catOfDiamonds); \ No newline at end of file From b0d255c3762a71df2754aaf972891cebf615e5a7 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Wed, 17 Dec 2025 12:09:53 +0100 Subject: [PATCH 32/93] Added Invalid card rank error throw. --- Sprint-3/1-key-implement/3-get-card-value.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-key-implement/3-get-card-value.js b/Sprint-3/1-key-implement/3-get-card-value.js index d40201f951..9ad6a5e0a1 100644 --- a/Sprint-3/1-key-implement/3-get-card-value.js +++ b/Sprint-3/1-key-implement/3-get-card-value.js @@ -26,6 +26,8 @@ function getCardValue(card) { return 10; case "A": return 11; + default: + throw new Error("Invalid card rank"); } } From 423908a2d358c5ba96e3660fc056545ebe867331 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:06:15 +0100 Subject: [PATCH 33/93] Copied th getAngleType(angle) function implementation from 1-key-implement/1-get-angle-type.js to 2-mandatory-rewrite/1-get-angle-type.js for sprint 3. --- .../2-mandatory-rewrite/1-get-angle-type.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js index d61254bd73..5c0033dcc9 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.js @@ -1,7 +1,20 @@ function getAngleType(angle) { if (angle === 90) return "Right angle"; - // replace with your completed function from key-implement - + if (angle === 90) { + return "Right angle"; + } + if (angle === 180) { + return "Straight angle"; + } + if (angle < 90) { + return "Acute angle"; + } + if (angle < 180) { + return "Obtuse angle"; + } + if (angle < 360) { + return "Reflex angle"; + } } From e40ee60c82d5a6bc8e4ba3de45c1d5218426fca5 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:16:31 +0100 Subject: [PATCH 34/93] Implemented a test for getAngleType(angle) function for the case of acuate angles in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index b62827b7c8..d8724db806 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -7,9 +7,9 @@ test("should identify right angle (90°)", () => { // REPLACE the comments with the tests // make your test descriptions as clear and readable as possible -// Case 2: Identify Acute Angles: -// When the angle is less than 90 degrees, -// Then the function should return "Acute angle" +test("Should identified acute angles (<90°)", () => { + expect(getAngleType(45)).toEqual("Acute angle"); +}); // Case 3: Identify Obtuse Angles: // When the angle is greater than 90 degrees and less than 180 degrees, From c82c1fe1a55c7e44ca091f45972144ae6066ffe5 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:24:16 +0100 Subject: [PATCH 35/93] Implemented a test for getAngleType(angle) function for the case of obtuse angles in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index d8724db806..f571e9cc31 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -7,13 +7,13 @@ test("should identify right angle (90°)", () => { // REPLACE the comments with the tests // make your test descriptions as clear and readable as possible -test("Should identified acute angles (<90°)", () => { +test("Should identified acute angles (angle < 90°)", () => { expect(getAngleType(45)).toEqual("Acute angle"); }); -// Case 3: Identify Obtuse Angles: -// When the angle is greater than 90 degrees and less than 180 degrees, -// Then the function should return "Obtuse angle" +test("Should identified obtuse angles (90° < angle < 180°)", () => { + expect(getAngleType(120)).toEqual("Obtuse angle"); +}); // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, From 8b8cc2aa733a64720b81896a99d31d131bdbc2df Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:36:31 +0100 Subject: [PATCH 36/93] Implemented a test for getAngleType(angle) function for the case of straight angle in sprint 3 mandatory rewrite section. --- .../2-mandatory-rewrite/1-get-angle-type.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index f571e9cc31..3940f674c0 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -1,23 +1,23 @@ const getAngleType = require("./1-get-angle-type"); -test("should identify right angle (90°)", () => { +test("should identify right angle (angle = 90°)", () => { expect(getAngleType(90)).toEqual("Right angle"); }); // REPLACE the comments with the tests // make your test descriptions as clear and readable as possible -test("Should identified acute angles (angle < 90°)", () => { +test("Should identify acute angles (angle < 90°)", () => { expect(getAngleType(45)).toEqual("Acute angle"); }); -test("Should identified obtuse angles (90° < angle < 180°)", () => { +test("Should identify obtuse angles (90° < angle < 180°)", () => { expect(getAngleType(120)).toEqual("Obtuse angle"); }); -// Case 4: Identify Straight Angles: -// When the angle is exactly 180 degrees, -// Then the function should return "Straight angle" +test("Should identify straight angle (angle = 180°)", () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, From 11265a6201eb7bcc52321b64f19701571d384340 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:41:43 +0100 Subject: [PATCH 37/93] Implemented a test for getAngleType(angle) function for the case of reflex angles in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js index 3940f674c0..65def21dc0 100644 --- a/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js +++ b/Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js @@ -19,6 +19,6 @@ test("Should identify straight angle (angle = 180°)", () => { expect(getAngleType(180)).toEqual("Straight angle"); }); -// Case 5: Identify Reflex Angles: -// When the angle is greater than 180 degrees and less than 360 degrees, -// Then the function should return "Reflex angle" +test("Should identify reflex angle (180° < angle < 360°)", () => { + expect(getAngleType(210)).toEqual("Reflex angle"); +}); \ No newline at end of file From f5079c369941d48ab8b6c8507ebc79abaa0dd78d Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 10:44:47 +0100 Subject: [PATCH 38/93] Copied the isProperFraction(numerator, denominator) function implementation from Sprint-3/1-key-implement/2-is-proper-fraction.js to Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js index 9836fe3985..cf91e9d441 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js @@ -1,6 +1,5 @@ function isProperFraction(numerator, denominator) { - if (numerator < denominator) return true; - // add your completed function from key-implement here + return Math.abs(numerator / denominator) < 1; } module.exports = isProperFraction; \ No newline at end of file From 75ec3e5903aa91e09c6b6445f77079eb50e7366c Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 11:53:54 +0100 Subject: [PATCH 39/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the improper fraction case in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index ff1cc8173c..07da0eeac8 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -4,7 +4,9 @@ test("should return true for a proper fraction", () => { expect(isProperFraction(2, 3)).toEqual(true); }); -// Case 2: Identify Improper Fractions: +test("Should return false for improper fraction", () => { + expect(isProperFraction(3, 2)).toEqual(false); +}); // Case 3: Identify Negative Fractions: From 00b30d994611b610433c8664c2ee896b040618e8 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:12:12 +0100 Subject: [PATCH 40/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for a proper negative fraction case in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index 07da0eeac8..f1366a7689 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -8,6 +8,8 @@ test("Should return false for improper fraction", () => { expect(isProperFraction(3, 2)).toEqual(false); }); -// Case 3: Identify Negative Fractions: +test("Should return true for a proper negative fraction", () => { + expect(isProperFraction(-2, 3)).toEqual(true); +}); // Case 4: Identify Equal Numerator and Denominator: From 12f638f80952ffe68a0019d51f64ad1effb39349 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:14:56 +0100 Subject: [PATCH 41/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the fraction case with equal positive numenator and denominator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index f1366a7689..e6924103e1 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -12,4 +12,6 @@ test("Should return true for a proper negative fraction", () => { expect(isProperFraction(-2, 3)).toEqual(true); }); -// Case 4: Identify Equal Numerator and Denominator: +test("Should return false for equal positive numerator and denominator", () => { + expect(isProperFraction(2, 2)).toEqual(false); +}); From 59c7010495fe0aaf0ff3e5cc979d5a9026821573 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:17:37 +0100 Subject: [PATCH 42/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the im proper negative fraction case in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index e6924103e1..ad164dba36 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -15,3 +15,7 @@ test("Should return true for a proper negative fraction", () => { test("Should return false for equal positive numerator and denominator", () => { expect(isProperFraction(2, 2)).toEqual(false); }); + +test("Should return false for negative improper fraction", () => { + expect(isProperFraction(-3, 2)).toEqual(false); +}); From aa2055d7da8a4e83de02e9603ae6fe34362c7e1d Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:30:59 +0100 Subject: [PATCH 43/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the proper fraction case with negative denominator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index ad164dba36..5adb7efa91 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -19,3 +19,7 @@ test("Should return false for equal positive numerator and denominator", () => { test("Should return false for negative improper fraction", () => { expect(isProperFraction(-3, 2)).toEqual(false); }); + +test("Should return true for proper fraction with negative denominator", () => { + expect(isProperFraction(2, -3)).toEqual(true); +}); From 9d7b538776dfa8cc549f51f6ddebec4ccf0821b0 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:35:27 +0100 Subject: [PATCH 44/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the im proper fraction case with a negative denominator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index 5adb7efa91..f1f3f53d97 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -16,10 +16,14 @@ test("Should return false for equal positive numerator and denominator", () => { expect(isProperFraction(2, 2)).toEqual(false); }); -test("Should return false for negative improper fraction", () => { +test("Should return false for a negative improper fraction", () => { expect(isProperFraction(-3, 2)).toEqual(false); }); -test("Should return true for proper fraction with negative denominator", () => { +test("Should return true for a proper fraction with negative denominator", () => { expect(isProperFraction(2, -3)).toEqual(true); }); + +test("Should return false for an improper fraction with negative denominator", () => { + expect(isProperFraction(3, -2)).toEqual(false); +}); From 56eea0367ebe8ad98f823d75991f4af0731f71da Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:37:48 +0100 Subject: [PATCH 45/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the proper fraction case with both negative parts in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index f1f3f53d97..e4624aa0b3 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -27,3 +27,7 @@ test("Should return true for a proper fraction with negative denominator", () => test("Should return false for an improper fraction with negative denominator", () => { expect(isProperFraction(3, -2)).toEqual(false); }); + +test("Should return true for a proper fraction with both negative parts", () => { + expect(isProperFraction(-2, -3)).toEqual(true); +}); From 04427e8c089e3244ea69c51ff9a5be2617998290 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:39:53 +0100 Subject: [PATCH 46/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the im proper fraction case with both negative parts in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index e4624aa0b3..6086e6581e 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -31,3 +31,7 @@ test("Should return false for an improper fraction with negative denominator", ( test("Should return true for a proper fraction with both negative parts", () => { expect(isProperFraction(-2, -3)).toEqual(true); }); + +test("Should return false false for an improper fraction with both negative fraction", () => { + expect(isProperFraction(-3, -2)).toEqual(false); +}); From 38b36c4728036b44666cb59e172a8e878dfcb5d4 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 12:42:15 +0100 Subject: [PATCH 47/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the fraction case with equal negative numerator and denominator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index 6086e6581e..647faa36fd 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -35,3 +35,7 @@ test("Should return true for a proper fraction with both negative parts", () => test("Should return false false for an improper fraction with both negative fraction", () => { expect(isProperFraction(-3, -2)).toEqual(false); }); + +test("Should return false for negative equal nominator and denominator", () => { + expect(isProperFraction(-2, -2)).toEqual(false); +}); From 276f7e769307c8be48f41f6b22a51d0616558c90 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:13:12 +0100 Subject: [PATCH 48/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the fraction case with zero numerator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index 647faa36fd..f729182c99 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -32,10 +32,14 @@ test("Should return true for a proper fraction with both negative parts", () => expect(isProperFraction(-2, -3)).toEqual(true); }); -test("Should return false false for an improper fraction with both negative fraction", () => { +test("Should return false false for an improper fraction with both negative parts", () => { expect(isProperFraction(-3, -2)).toEqual(false); }); -test("Should return false for negative equal nominator and denominator", () => { +test("Should return false for negative equal numerator and denominator", () => { expect(isProperFraction(-2, -2)).toEqual(false); }); + +test("Should return true for a fraction with zero numerator", () => { + expect(isProperFraction(0, 2)).toEqual(true); +}); \ No newline at end of file From a06d634a13823d33c3915a0b39cb9d9562c902b7 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:16:02 +0100 Subject: [PATCH 49/93] Implemet a test for the isProperFrcation(numeratot, denominator) function for the fraction case with zero denominator in sprint 3 mandatory rewrite section. --- Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js index f729182c99..3ef1fb2cb6 100644 --- a/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js +++ b/Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js @@ -42,4 +42,8 @@ test("Should return false for negative equal numerator and denominator", () => { test("Should return true for a fraction with zero numerator", () => { expect(isProperFraction(0, 2)).toEqual(true); +}); + +test("Should return false for a fraction with zero denominator", () => { + expect(isProperFraction(2, 0)).toEqual(false); }); \ No newline at end of file From a3fc541f436d4c852633d626114b163c915a05b7 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:17:44 +0100 Subject: [PATCH 50/93] Fixed error in assertion case of zero denominator for function isProperFrcation(numerator, denominator) in Sprint-3/1-key-implement/2-is-proper-fraction.js. --- Sprint-3/1-key-implement/2-is-proper-fraction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-implement/2-is-proper-fraction.js b/Sprint-3/1-key-implement/2-is-proper-fraction.js index 0e67f73db8..ed8536f1a1 100644 --- a/Sprint-3/1-key-implement/2-is-proper-fraction.js +++ b/Sprint-3/1-key-implement/2-is-proper-fraction.js @@ -107,5 +107,5 @@ assertEquals(zeroNumerator, true); // Input: numerator = 2 denominator = 0 // Target output: false // Explanation: the fraction 2/0 is a improper fraction because the absolute value of the numerator (2) greater than the denominator (0). -const zeroDenominator = isProperFraction(0, 2); -assertEquals(zeroDenominator, true); \ No newline at end of file +const zeroDenominator = isProperFraction(2, 0); +assertEquals(zeroDenominator, false); \ No newline at end of file From 968f2277c068f907a4e08934c6b47101a6db05ce Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:27:29 +0100 Subject: [PATCH 51/93] Copied the logic implementation for the getCardValue(card) function from Sprint-3/1-key-implement/3-get-card-value.js to Sprint-3/2-mandatory-rewrite/3-get-card-value.js --- .../2-mandatory-rewrite/3-get-card-value.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js index 0d95d3736f..457daafe77 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js @@ -1,5 +1,24 @@ function getCardValue(card) { - // replace with your code from key-implement - return 11; + const rank = card.slice(0, card.length - 1); + switch (rank) { + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + case "9": + return Number(rank); + case "10": + case "J": + case "Q": + case "K": + return 10; + case "A": + return 11; + default: + throw new Error("Invalid card rank"); + } } module.exports = getCardValue; \ No newline at end of file From a61f5846ef83ff75c58458b22488b98ed4370766 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:38:38 +0100 Subject: [PATCH 52/93] Implemented tests for Number cards for the getCardValue(card) function in the sprint 3 mandatory rewrite part. --- .../3-get-card-value.test.js | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 03a8e2f341..6818e1deb4 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -1,11 +1,45 @@ const getCardValue = require("./3-get-card-value"); -test("should return 11 for Ace of Spades", () => { - const aceofSpades = getCardValue("A♠"); - expect(aceofSpades).toEqual(11); +test("Should return 11 for Ace of Spades", () => { + const aceOfSpades = getCardValue("A♠"); + expect(aceOfSpades).toEqual(11); }); // Case 2: Handle Number Cards (2-10): +test("Should return 2 for Two of Hearts", () => { + const twoOfHearts = "2♥"; + expect(getCardValue(twoOfHearts)).toEqual(2); +}); + +test("Should return 3 for Three of Hearts", () => { + const threeOfHearts = "3♥"; + expect(getCardValue(threeOfHearts)).toEqual(3); +}); + +test("Should return 4 for Four of Hearts", () => { + const fourOfHearts = "4♥"; + expect(getCardValue(fourOfHearts)).toEqual(4); +}); + +test("Should return 5 for Five of Hearts", () => { + const fiveOfHearts = "5♥"; + expect(getCardValue(fiveOfHearts)).toEqual(5); +}); + +test("Should return 6 for Six of Hearts", () => { + const sixOfHearts = "6♥"; + expect(getCardValue(sixOfHearts)).toEqual(6); +}); + +test("Should return 7 for Seven of Hearts", () => { + const sevenOfHearts = "7♥"; + expect(getCardValue(sevenOfHearts)).toEqual(7); +}); + +test("Should return 8 for Eight of Hearts", () => { + const eightOfHearts = "8♥"; + expect(getCardValue(eightOfHearts)).toEqual(8); +}); // Case 3: Handle Face Cards (J, Q, K): // Case 4: Handle Ace (A): // Case 5: Handle Invalid Cards: From 1a6b8d0be6a1a0d786d5ae1b546596874f7f4e33 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:53:48 +0100 Subject: [PATCH 53/93] Implemented test for cards of Nine for the getCardValue(card) function in the sprint 3 mandatory rewrite part. --- Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 6818e1deb4..8523a05644 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -40,6 +40,12 @@ test("Should return 8 for Eight of Hearts", () => { const eightOfHearts = "8♥"; expect(getCardValue(eightOfHearts)).toEqual(8); }); -// Case 3: Handle Face Cards (J, Q, K): + +test("Should return 9 for Nine of Hearts", () => { + const nineOfHearts = "9♥"; + expect(getCardValue(nineOfHearts)).toEqual(9); +}); + +// Case 3: Handle Face Cards (10, J, Q, K): // Case 4: Handle Ace (A): // Case 5: Handle Invalid Cards: From 7e6b899d8d1ecf5f21deb8535dc3d4f74a89ca3c Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 21:58:11 +0100 Subject: [PATCH 54/93] Implemented tests for Face cards for the getCardValue(card) function in the sprint 3 mandatory rewrite part. --- .../3-get-card-value.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 8523a05644..7f5955b959 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -47,5 +47,25 @@ test("Should return 9 for Nine of Hearts", () => { }); // Case 3: Handle Face Cards (10, J, Q, K): +test("Should return 10 for Ten of Clubs", () => { + const tenOfClubs = "10♣"; + expect(getCardValue(tenOfClubs)).toEqual(10); +}); + +test("Should return 10 for Jack of Clubs", () => { + const jackOfClubs = "J♣"; + expect(getCardValue(jackOfClubs)).toEqual(10); +}); + +test("Should return 10 for Queen of Clubs", () => { + const queenOfClubs = "Q♣"; + expect(getCardValue(queenOfClubs)).toEqual(10); +}); + +test("Should return 10 for King of Clubs", () => { + const kingOfClubs = "K♣"; + expect(getCardValue(kingOfClubs)).toEqual(10); +}); + // Case 4: Handle Ace (A): // Case 5: Handle Invalid Cards: From ec83b75955a99a753ee34e9ce532ad468a0e3fcd Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 22:00:46 +0100 Subject: [PATCH 55/93] Moved the test implementation for Ace cards for the getCardValue(card) function in the sprint 3 mandatory rewrite part. --- Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 7f5955b959..41937afa77 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -1,10 +1,5 @@ const getCardValue = require("./3-get-card-value"); -test("Should return 11 for Ace of Spades", () => { - const aceOfSpades = getCardValue("A♠"); - expect(aceOfSpades).toEqual(11); - }); - // Case 2: Handle Number Cards (2-10): test("Should return 2 for Two of Hearts", () => { const twoOfHearts = "2♥"; @@ -68,4 +63,9 @@ test("Should return 10 for King of Clubs", () => { }); // Case 4: Handle Ace (A): +test("Should return 11 for Ace of Spades", () => { + const aceOfSpades = getCardValue("A♠"); + expect(aceOfSpades).toEqual(11); +}); + // Case 5: Handle Invalid Cards: From 796d974a5da167565a7fb2224f0bcf172adbd0bd Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 22:03:43 +0100 Subject: [PATCH 56/93] Moved test for cards of Ten for the getCardValue(card) function in the Number cards case section in the sprint 3 mandatory rewrite part. --- Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 41937afa77..9f400daff2 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -41,12 +41,12 @@ test("Should return 9 for Nine of Hearts", () => { expect(getCardValue(nineOfHearts)).toEqual(9); }); -// Case 3: Handle Face Cards (10, J, Q, K): -test("Should return 10 for Ten of Clubs", () => { - const tenOfClubs = "10♣"; +test("Should return 10 for Ten of Hearts", () => { + const tenOfClubs = "10♥"; expect(getCardValue(tenOfClubs)).toEqual(10); }); +// Case 3: Handle Face Cards (J, Q, K): test("Should return 10 for Jack of Clubs", () => { const jackOfClubs = "J♣"; expect(getCardValue(jackOfClubs)).toEqual(10); From daccbe1d48aa47e582e017e808cb24d7d91ab5f3 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 22:06:35 +0100 Subject: [PATCH 57/93] Update logic of the getCardValue(card) function. Case of cards of Ten moved in the Number cards case handling part in the sprint 3 mandatory rewrite part. --- Sprint-3/2-mandatory-rewrite/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js index 457daafe77..703becb2c4 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.js @@ -9,8 +9,8 @@ function getCardValue(card) { case "7": case "8": case "9": - return Number(rank); case "10": + return Number(rank); case "J": case "Q": case "K": From 423111c4935ef4273c60e6b4c4927d549de2abb5 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Thu, 18 Dec 2025 22:17:45 +0100 Subject: [PATCH 58/93] Implemented tests for handling errors of Invalid cards for the getCardValue(card) function in the sprint 3 mandatory rewrite part. --- .../3-get-card-value.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js index 9f400daff2..9d5cf6e974 100644 --- a/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js +++ b/Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js @@ -69,3 +69,22 @@ test("Should return 11 for Ace of Spades", () => { }); // Case 5: Handle Invalid Cards: +test("Should throw the 'Invalid card rank' error for One of Diamonds", () => { + const oneOfDiamonds = "1♦"; + expect(() => getCardValue(oneOfDiamonds)).toThrowError("Invalid card rank"); +}); + +test("Should throw the 'Invalid card rank' error for One of Diamonds", () => { + const twentyOneOfDiamonds = "21♦"; + expect(() => getCardValue(twentyOneOfDiamonds)).toThrowError("Invalid card rank"); +}); + +test("Should throw the 'Invalid card rank' error for One of Diamonds", () => { + const oneHundredOfDiamonds = "100♦"; + expect(() => getCardValue(oneHundredOfDiamonds)).toThrowError("Invalid card rank"); +}); + +test("Should throw the 'Invalid card rank' error for One of Diamonds", () => { + const catOfDiamonds = "C♦"; + expect(() => getCardValue(catOfDiamonds)).toThrowError("Invalid card rank"); +}); \ No newline at end of file From 6c1ba583c58b14c77e765a94742fc1decde0ccc3 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 11:45:19 +0100 Subject: [PATCH 59/93] Added a test for the countChar(string, char) function in case of the char doesn't exists in the string in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/count.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/count.test.js b/Sprint-3/3-mandatory-practice/implement/count.test.js index 42baf4b4b0..2deee650ec 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.test.js +++ b/Sprint-3/3-mandatory-practice/implement/count.test.js @@ -22,3 +22,10 @@ test("should count multiple occurrences of a character", () => { // And a character char that does not exist within the case-sensitive str, // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. + +test("", () => { + const str = "AAAAA"; + const char = "a"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); From dccbd3716ae6e1eadc31619602d9aa994461a476 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 11:54:27 +0100 Subject: [PATCH 60/93] Updated the countChar(string, char) function logic for correct work in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/count.js | 8 +++++++- Sprint-3/3-mandatory-practice/implement/count.test.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/count.js b/Sprint-3/3-mandatory-practice/implement/count.js index fce2496501..3c371d4ed4 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.js +++ b/Sprint-3/3-mandatory-practice/implement/count.js @@ -1,5 +1,11 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 + let count = 0; + for (let char of stringOfCharacters) { + if (char === findCharacter) { + count++; + } + } + return count; } module.exports = countChar; \ No newline at end of file diff --git a/Sprint-3/3-mandatory-practice/implement/count.test.js b/Sprint-3/3-mandatory-practice/implement/count.test.js index 2deee650ec..2c1c032e2c 100644 --- a/Sprint-3/3-mandatory-practice/implement/count.test.js +++ b/Sprint-3/3-mandatory-practice/implement/count.test.js @@ -23,7 +23,7 @@ test("should count multiple occurrences of a character", () => { // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. -test("", () => { +test("Should return 0 for string without the searching character", () => { const str = "AAAAA"; const char = "a"; const count = countChar(str, char); From dca6fd25272708338c3ab16fcfbe8ffc5e429253 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 12:09:49 +0100 Subject: [PATCH 61/93] Added a test for the repeat(str, count) function in case of repeat count is 1 in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/repeat.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.test.js b/Sprint-3/3-mandatory-practice/implement/repeat.test.js index 8a4ab42efc..0df0772f74 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.test.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.test.js @@ -21,6 +21,13 @@ test("should repeat the string count times", () => { // When the repeat function is called with these inputs, // Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition. +test("Should return the original string", () => { + const str = "hello"; + const count = 1; + const repeatedString = repeat(str, count); + expect(repeatedString).toEqual(str); +}); + // case: Handle Count of 0: // Given a target string str and a count equal to 0, // When the repeat function is called with these inputs, From 0c5a7fe7bdfd6ccb2341c0e7e5ec846a8f5c1903 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 12:13:21 +0100 Subject: [PATCH 62/93] Added a test for the repeat(str, count) function in case of repeat count is 0 in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/repeat.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.test.js b/Sprint-3/3-mandatory-practice/implement/repeat.test.js index 0df0772f74..c1a8a6f5ff 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.test.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.test.js @@ -21,7 +21,7 @@ test("should repeat the string count times", () => { // When the repeat function is called with these inputs, // Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition. -test("Should return the original string", () => { +test("Should return the original string for count = 1", () => { const str = "hello"; const count = 1; const repeatedString = repeat(str, count); @@ -32,6 +32,12 @@ test("Should return the original string", () => { // Given a target string str and a count equal to 0, // When the repeat function is called with these inputs, // Then it should return an empty string, ensuring that a count of 0 results in an empty output. +test("Should return empty string for count = 0", () => { + const str = "hello"; + const count = 0; + const repeatedString = repeat(str, count); + expect(repeatedString).toEqual(""); +}) // case: Negative Count: // Given a target string str and a negative integer count, From 73e2b5e25a274b278304d17523da3f9fd162e948 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 12:20:19 +0100 Subject: [PATCH 63/93] Added a test for the repeat(str, count) function in case of a negative count repeat in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/repeat.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.test.js b/Sprint-3/3-mandatory-practice/implement/repeat.test.js index c1a8a6f5ff..822bb93a00 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.test.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.test.js @@ -32,6 +32,7 @@ test("Should return the original string for count = 1", () => { // Given a target string str and a count equal to 0, // When the repeat function is called with these inputs, // Then it should return an empty string, ensuring that a count of 0 results in an empty output. + test("Should return empty string for count = 0", () => { const str = "hello"; const count = 0; @@ -43,3 +44,9 @@ test("Should return empty string for count = 0", () => { // Given a target string str and a negative integer count, // When the repeat function is called with these inputs, // Then it should throw an error or return an appropriate error message, as negative counts are not valid. + +test("Should throw a Range error for a negative count", () => { + const str = "hello"; + const count = -1; + expect(() => {repeat(str, count)}).toThrow(); +}); \ No newline at end of file From 1678804480121330372a7fff4b0bd613e88f2a33 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 12:22:32 +0100 Subject: [PATCH 64/93] Update the implementaion of the repeat(str, count) function for correct work in sprint 3 mandatory practice / implement part. --- Sprint-3/3-mandatory-practice/implement/repeat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/repeat.js b/Sprint-3/3-mandatory-practice/implement/repeat.js index 621f9bd35b..28e67af671 100644 --- a/Sprint-3/3-mandatory-practice/implement/repeat.js +++ b/Sprint-3/3-mandatory-practice/implement/repeat.js @@ -1,5 +1,5 @@ -function repeat() { - return "hellohellohello"; +function repeat(stringToRepeat, repeatCount) { + return stringToRepeat.repeat(repeatCount); } module.exports = repeat; \ No newline at end of file From bf0a77a02585b6c5dc667673984f60945037a160 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 20:41:49 +0100 Subject: [PATCH 65/93] Added a test for the getOrdinalNumber(num) function for the case num = 2 in sprint 3 mandatory practice/implement part. --- .../implement/get-ordinal-number.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 6d55dfbb40..d07aba7c93 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -9,5 +9,9 @@ const getOrdinalNumber = require("./get-ordinal-number"); // Then the function should return "1st" test("should return '1st' for 1", () => { - expect(getOrdinalNumber(1)).toEqual("1st"); - }); + expect(getOrdinalNumber(1)).toEqual("1st"); +}); + +test("Should return '2nd' for '2'", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); +}); From bb4f50ad1dd5442826cba2fe9dc5af624fa1f2af Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 20:55:11 +0100 Subject: [PATCH 66/93] Added tests for the getOrdinalNumber(num) function for numbers ending in 1 except ending 11 in sprint 3 mandatory practice/implement part. --- .../implement/get-ordinal-number.js | 2 +- .../implement/get-ordinal-number.test.js | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 24f528b0d3..dfa78cfb25 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -1,5 +1,5 @@ function getOrdinalNumber(num) { - return "1st"; + return "1st"; } module.exports = getOrdinalNumber; \ No newline at end of file diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index d07aba7c93..fdbca6c4eb 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -4,14 +4,28 @@ const getOrdinalNumber = require("./get-ordinal-number"); // continue testing and implementing getOrdinalNumber for additional cases // Write your tests using Jest - remember to run your tests often for continual feedback -// Case 1: Identify the ordinal number for 1 -// When the number is 1, -// Then the function should return "1st" +// Case 1: Identify the ordinal numbers ending in 1 except ending in 11 test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); -test("Should return '2nd' for '2'", () => { - expect(getOrdinalNumber(2)).toEqual("2nd"); +test("Should return '11th' for '11'", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); +}) + +test("should return '21st' for 21", () => { + expect(getOrdinalNumber(21)).toEqual("21st"); +}); + +test("Should return '101st' for '101'", () => { + expect(getOrdinalNumber(101)).toEqual("101st"); +}); + +test("Should return '111th' for '111'", () => { + expect(getOrdinalNumber(111)).toEqual("111th"); +}); + +test("should return '121st' for 121", () => { + expect(getOrdinalNumber(121)).toEqual("121st"); }); From b32ba5ff143585f8a72f7d9fda59adf4a55492aa Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:06:36 +0100 Subject: [PATCH 67/93] Implemented the getOrdinalNumber(num) function logic in case of numbers ending in 1 in sprint 3 mandatory practice/implement part. --- .../implement/get-ordinal-number.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index dfa78cfb25..875b87bf71 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -1,5 +1,13 @@ function getOrdinalNumber(num) { - return "1st"; + const lastDigit = num % 10; + const last2Digits = num % 100; + console.log(`${num} ${lastDigit} ${last2Digits}`); + if (lastDigit === 1) { + if (last2Digits === 11) { + return num + "th"; + } + return num + "st"; + } } module.exports = getOrdinalNumber; \ No newline at end of file From d517b6189110783552a9388c6afb00503fc22590 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:15:11 +0100 Subject: [PATCH 68/93] Added tests for the getOrdinalNumber(num) function for numbers ending in 2 in sprint 3 mandatory practice/implement part. --- .../implement/get-ordinal-number.test.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index fdbca6c4eb..a634d81cd6 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -4,7 +4,8 @@ const getOrdinalNumber = require("./get-ordinal-number"); // continue testing and implementing getOrdinalNumber for additional cases // Write your tests using Jest - remember to run your tests often for continual feedback -// Case 1: Identify the ordinal numbers ending in 1 except ending in 11 +// Case 1: Identify the ordinal for numbers ending in 1. Should return ordinals ending in '1st' +// except numbers ending in 11 for which should return ordinals ending in '11th' test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); @@ -29,3 +30,30 @@ test("Should return '111th' for '111'", () => { test("should return '121st' for 121", () => { expect(getOrdinalNumber(121)).toEqual("121st"); }); + +// Case 2: Identify the ordinal for numbers ending in 2. Should return ordinals ending in '2nd' +// except numbers ending in 12 for which should return ordinals ending in '12th' + +test("should return '2nd' for 2", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); +}); + +test("Should return '12th' for '12'", () => { + expect(getOrdinalNumber(12)).toEqual("12th"); +}); + +test("should return '22nd' for 22", () => { + expect(getOrdinalNumber(22)).toEqual("22nd"); +}); + +test("Should return '102nd' for '102'", () => { + expect(getOrdinalNumber(101)).toEqual("102nd"); +}); + +test("Should return '112th' for '112'", () => { + expect(getOrdinalNumber(112)).toEqual("112th"); +}); + +test("should return '122nd' for 122", () => { + expect(getOrdinalNumber(121)).toEqual("122nd"); +}); \ No newline at end of file From 14ffc07fbeaa96cdc174f52252c1295f26b55040 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:18:21 +0100 Subject: [PATCH 69/93] Implemented the getOrdinalNumber(num) function logic in case of numbers ending in 2 in sprint 3 mandatory practice/implement part. Fixed tests for number equal 102 and 122. --- .../3-mandatory-practice/implement/get-ordinal-number.js | 6 ++++++ .../implement/get-ordinal-number.test.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 875b87bf71..ef703621bd 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -8,6 +8,12 @@ function getOrdinalNumber(num) { } return num + "st"; } + if (lastDigit === 2) { + if (last2Digits === 12) { + return num + "th"; + } + return num + "nd"; + } } module.exports = getOrdinalNumber; \ No newline at end of file diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index a634d81cd6..53272f0f49 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -47,7 +47,7 @@ test("should return '22nd' for 22", () => { }); test("Should return '102nd' for '102'", () => { - expect(getOrdinalNumber(101)).toEqual("102nd"); + expect(getOrdinalNumber(102)).toEqual("102nd"); }); test("Should return '112th' for '112'", () => { @@ -55,5 +55,5 @@ test("Should return '112th' for '112'", () => { }); test("should return '122nd' for 122", () => { - expect(getOrdinalNumber(121)).toEqual("122nd"); + expect(getOrdinalNumber(122)).toEqual("122nd"); }); \ No newline at end of file From cc8c7c9065038e9c08569384caea0565ff88c85b Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:25:09 +0100 Subject: [PATCH 70/93] Added tests for the getOrdinalNumber(num) function for numbers ending in 3 in sprint 3 mandatory practice/implement part. --- .../implement/get-ordinal-number.test.js | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 53272f0f49..06b29fbe3e 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -7,7 +7,7 @@ const getOrdinalNumber = require("./get-ordinal-number"); // Case 1: Identify the ordinal for numbers ending in 1. Should return ordinals ending in '1st' // except numbers ending in 11 for which should return ordinals ending in '11th' -test("should return '1st' for 1", () => { +test("Should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); @@ -15,7 +15,7 @@ test("Should return '11th' for '11'", () => { expect(getOrdinalNumber(11)).toEqual("11th"); }) -test("should return '21st' for 21", () => { +test("Should return '21st' for 21", () => { expect(getOrdinalNumber(21)).toEqual("21st"); }); @@ -27,14 +27,14 @@ test("Should return '111th' for '111'", () => { expect(getOrdinalNumber(111)).toEqual("111th"); }); -test("should return '121st' for 121", () => { +test("Should return '121st' for 121", () => { expect(getOrdinalNumber(121)).toEqual("121st"); }); // Case 2: Identify the ordinal for numbers ending in 2. Should return ordinals ending in '2nd' // except numbers ending in 12 for which should return ordinals ending in '12th' -test("should return '2nd' for 2", () => { +test("Should return '2nd' for 2", () => { expect(getOrdinalNumber(2)).toEqual("2nd"); }); @@ -42,7 +42,7 @@ test("Should return '12th' for '12'", () => { expect(getOrdinalNumber(12)).toEqual("12th"); }); -test("should return '22nd' for 22", () => { +test("Should return '22nd' for 22", () => { expect(getOrdinalNumber(22)).toEqual("22nd"); }); @@ -54,6 +54,33 @@ test("Should return '112th' for '112'", () => { expect(getOrdinalNumber(112)).toEqual("112th"); }); -test("should return '122nd' for 122", () => { +test("Should return '122nd' for 122", () => { expect(getOrdinalNumber(122)).toEqual("122nd"); +}); + +// Case 3: Identify the ordinal for numbers ending in 3. Should return ordinals ending in '3rd' +// except numbers ending in 13 for which should return ordinals ending in '13th' + +test("Should return '3rd' for 3", () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); +}); + +test("Should return '13th' for '13'", () => { + expect(getOrdinalNumber(13)).toEqual("13th"); +}); + +test("Should return '23rd' for 23", () => { + expect(getOrdinalNumber(23)).toEqual("23rd"); +}); + +test("Should return '103rd' for '103'", () => { + expect(getOrdinalNumber(103)).toEqual("103rd"); +}); + +test("Should return '113th' for '113'", () => { + expect(getOrdinalNumber(113)).toEqual("113th"); +}); + +test("Should return '123rd' for 123", () => { + expect(getOrdinalNumber(123)).toEqual("123rd"); }); \ No newline at end of file From 5b5ae9df782aca67708c28dd5ea8cbce14eacdb1 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:26:28 +0100 Subject: [PATCH 71/93] Implemented the getOrdinalNumber(num) function logic in case of numbers ending in 3 in sprint 3 mandatory practice/implement part. --- .../3-mandatory-practice/implement/get-ordinal-number.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index ef703621bd..451d3bef72 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -14,6 +14,12 @@ function getOrdinalNumber(num) { } return num + "nd"; } + if (lastDigit === 3) { + if (last2Digits === 13) { + return num + "th"; + } + return num + "rd"; + } } module.exports = getOrdinalNumber; \ No newline at end of file From 45142134d59086df2f8eb98b44f67b9da7f3c2f8 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:32:43 +0100 Subject: [PATCH 72/93] Added tests for the getOrdinalNumber(num) function for rest numbers in sprint 3 mandatory practice/implement part. Updated tests messages. --- .../implement/get-ordinal-number.test.js | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 06b29fbe3e..1d5fa1ffa6 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -11,7 +11,7 @@ test("Should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); -test("Should return '11th' for '11'", () => { +test("Should return '11th' for 11", () => { expect(getOrdinalNumber(11)).toEqual("11th"); }) @@ -19,11 +19,11 @@ test("Should return '21st' for 21", () => { expect(getOrdinalNumber(21)).toEqual("21st"); }); -test("Should return '101st' for '101'", () => { +test("Should return '101st' for 101", () => { expect(getOrdinalNumber(101)).toEqual("101st"); }); -test("Should return '111th' for '111'", () => { +test("Should return '111th' for 111", () => { expect(getOrdinalNumber(111)).toEqual("111th"); }); @@ -38,7 +38,7 @@ test("Should return '2nd' for 2", () => { expect(getOrdinalNumber(2)).toEqual("2nd"); }); -test("Should return '12th' for '12'", () => { +test("Should return '12th' for 12", () => { expect(getOrdinalNumber(12)).toEqual("12th"); }); @@ -46,11 +46,11 @@ test("Should return '22nd' for 22", () => { expect(getOrdinalNumber(22)).toEqual("22nd"); }); -test("Should return '102nd' for '102'", () => { +test("Should return '102nd' for 102", () => { expect(getOrdinalNumber(102)).toEqual("102nd"); }); -test("Should return '112th' for '112'", () => { +test("Should return '112th' for 112", () => { expect(getOrdinalNumber(112)).toEqual("112th"); }); @@ -65,7 +65,7 @@ test("Should return '3rd' for 3", () => { expect(getOrdinalNumber(3)).toEqual("3rd"); }); -test("Should return '13th' for '13'", () => { +test("Should return '13th' for 13", () => { expect(getOrdinalNumber(13)).toEqual("13th"); }); @@ -73,14 +73,40 @@ test("Should return '23rd' for 23", () => { expect(getOrdinalNumber(23)).toEqual("23rd"); }); -test("Should return '103rd' for '103'", () => { +test("Should return '103rd' for 103", () => { expect(getOrdinalNumber(103)).toEqual("103rd"); }); -test("Should return '113th' for '113'", () => { +test("Should return '113th' for 113", () => { expect(getOrdinalNumber(113)).toEqual("113th"); }); test("Should return '123rd' for 123", () => { expect(getOrdinalNumber(123)).toEqual("123rd"); +}); + +// Case 3: Identify the ordinal for numbers ending in 4 to 0. Should return ordinals ending in 'th'. + +test("Should return '4th' for 4", () => { + expect(getOrdinalNumber(4)).toEqual("4th"); +}); + +test("Should return '15th' for 15", () => { + expect(getOrdinalNumber(15)).toEqual("15th"); +}); + +test("Should return '26th' for 26", () => { + expect(getOrdinalNumber(26)).toEqual("26th"); +}); + +test("Should return '107th' for 107", () => { + expect(getOrdinalNumber(107)).toEqual("107th"); +}); + +test("Should return '288th' for 288", () => { + expect(getOrdinalNumber(288)).toEqual("288th"); +}); + +test("Should return '1039th' for 1039", () => { + expect(getOrdinalNumber(1039)).toEqual("1039th"); }); \ No newline at end of file From af52834442bda01103d6aef24dd209ed7de283aa Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:34:26 +0100 Subject: [PATCH 73/93] Implemented the getOrdinalNumber(num) function logic for rest numbers in sprint 3 mandatory practice/implement part. --- Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 451d3bef72..55385c8dc1 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -20,6 +20,7 @@ function getOrdinalNumber(num) { } return num + "rd"; } + return num + "th"; } module.exports = getOrdinalNumber; \ No newline at end of file From d6438d78e94ab3ed833855546b6cee340d084b19 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:44:12 +0100 Subject: [PATCH 74/93] Added a test for the getOrdinalNumber(num) function for non numeric argument in sprint 3 mandatory practice/implement part. Updated tests messages. --- .../implement/get-ordinal-number.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 1d5fa1ffa6..b5573a7329 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -109,4 +109,10 @@ test("Should return '288th' for 288", () => { test("Should return '1039th' for 1039", () => { expect(getOrdinalNumber(1039)).toEqual("1039th"); +}); + +//Case 4: Identify invalid type of argument. + +test("", () => { + expect(() => {getOrdinalNumber("10")}).toThrow(); }); \ No newline at end of file From 1efb229e5533242b2aff8e6d5fd5c6eaed969b77 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:48:48 +0100 Subject: [PATCH 75/93] Implemented the getOrdinalNumber(num) function logic for non-numeric argument in sprint 3 mandatory practice/implement part. --- .../3-mandatory-practice/implement/get-ordinal-number.js | 8 ++++++++ .../implement/get-ordinal-number.test.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 55385c8dc1..5b31113b6a 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -1,6 +1,11 @@ function getOrdinalNumber(num) { + if (typeof num !== "number") { + throw new TypeError(`'${num}' is not a number.`); + } + const lastDigit = num % 10; const last2Digits = num % 100; + console.log(`${num} ${lastDigit} ${last2Digits}`); if (lastDigit === 1) { if (last2Digits === 11) { @@ -8,18 +13,21 @@ function getOrdinalNumber(num) { } return num + "st"; } + if (lastDigit === 2) { if (last2Digits === 12) { return num + "th"; } return num + "nd"; } + if (lastDigit === 3) { if (last2Digits === 13) { return num + "th"; } return num + "rd"; } + return num + "th"; } diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index b5573a7329..488fbe296e 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -113,6 +113,6 @@ test("Should return '1039th' for 1039", () => { //Case 4: Identify invalid type of argument. -test("", () => { +test("Should throw TypeError if num is not Number", () => { expect(() => {getOrdinalNumber("10")}).toThrow(); }); \ No newline at end of file From 63aa44f03fee991fc0700c62ac04b353fb6beb2c Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:52:48 +0100 Subject: [PATCH 76/93] Added a test for the getOrdinalNumber(num) function for float argument in sprint 3 mandatory practice/implement part --- .../implement/get-ordinal-number.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 488fbe296e..34e33b055d 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -115,4 +115,10 @@ test("Should return '1039th' for 1039", () => { test("Should throw TypeError if num is not Number", () => { expect(() => {getOrdinalNumber("10")}).toThrow(); +}); + +//Case 4: Identify float argument. + +test("Should throw RangeError if num is float", () => { + expect(() => {getOrdinalNumber(2.71)}).toThrow(); }); \ No newline at end of file From 96117e32be992498cdf4cb0dcf8de9dfe6a9f1b4 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:54:52 +0100 Subject: [PATCH 77/93] Implemented the getOrdinalNumber(num) function logic for float argument in sprint 3 mandatory practice/implement part. --- Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index 5b31113b6a..f2cf851a03 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -3,6 +3,10 @@ function getOrdinalNumber(num) { throw new TypeError(`'${num}' is not a number.`); } + if (!Number.isInteger(num)) { + throw new RangeError(`'${num}' is float`); + } + const lastDigit = num % 10; const last2Digits = num % 100; From a9143fd20e7774ddb4a491914989e12dbc44c2fc Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 21:58:25 +0100 Subject: [PATCH 78/93] Added tests for the getOrdinalNumber(num) function for non natural argument in sprint 3 mandatory practice/implement part --- .../implement/get-ordinal-number.test.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js index 34e33b055d..700f2546e6 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js @@ -117,8 +117,18 @@ test("Should throw TypeError if num is not Number", () => { expect(() => {getOrdinalNumber("10")}).toThrow(); }); -//Case 4: Identify float argument. +//Case 5: Identify float argument. test("Should throw RangeError if num is float", () => { expect(() => {getOrdinalNumber(2.71)}).toThrow(); +}); + +//Case 6: Identify non natural argument + +test("Should throw Range error for 0", () => { + expect(() => {getOrdinalNumber(0)}).toThrow(); +}); + +test("Should throw Range error for negative num", () => { + expect(() => {getOrdinalNumber(-1);}).toThrow(); }); \ No newline at end of file From 4615212ffb3400afece2a94547d80a10d126f3f1 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Fri, 19 Dec 2025 22:00:07 +0100 Subject: [PATCH 79/93] Implemented the getOrdinalNumber(num) function logic for non natural argument in sprint 3 mandatory practice/implement part. --- Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js index f2cf851a03..1cfb230c19 100644 --- a/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js +++ b/Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js @@ -7,6 +7,10 @@ function getOrdinalNumber(num) { throw new RangeError(`'${num}' is float`); } + if (num < 1) { + throw new RangeError(`'${num}' is not natural number`); + } + const lastDigit = num % 10; const last2Digits = num % 100; From 8b9783398c8d3652e253a2cf4f0aea2c7791ab23 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 18:29:50 +0100 Subject: [PATCH 80/93] Added answers in the find.js file in sprint 3 stretch investigate part. --- Sprint-3/4-stretch-investigate/find.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-3/4-stretch-investigate/find.js b/Sprint-3/4-stretch-investigate/find.js index c7e79a2f21..4b7e7ab87f 100644 --- a/Sprint-3/4-stretch-investigate/find.js +++ b/Sprint-3/4-stretch-investigate/find.js @@ -20,6 +20,14 @@ console.log(find("code your future", "z")); // Pay particular attention to the following: // a) How the index variable updates during the call to find +// In the begin of function after the declaration the index variable initialize with value 0. +// Then in the end of the every iteration of the while loop it increased by 1. + // b) What is the if statement used to check +// The if statement checks the value of the index variable exceeds the string last character iindex. + // c) Why is index++ being used? +// Because we the while loop without a counter instead of a for loop with the known count of iteration. + // d) What is the condition index < str.length used for? +// This condition indicate reaching of the end of the given string and exiting from the while loop. From 058c60518d0b427d53953a457f44fb4fe3c07438 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 18:37:49 +0100 Subject: [PATCH 81/93] In sprint 3 stretch investigate part for the function passwordValidator: - refactored the logic of checking that a password has at least 5 characters; - updated test notation to check a password minimal length. --- .../4-stretch-investigate/password-validator.js | 5 ++++- .../password-validator.test.js | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index b55d527dba..b43da707c7 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -1,5 +1,8 @@ function passwordValidator(password) { - return password.length < 5 ? false : true + if (password.length < 5) { + return false; + } + return true; } diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 8fa3089d6b..757cc86a56 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -15,12 +15,12 @@ To be valid, a password must: You must breakdown this problem in order to solve it. Find one test case first and get that working */ const isValidPassword = require("./password-validator"); + test("password has at least 5 characters", () => { - // Arrange - const password = "12345"; - // Act - const result = isValidPassword(password); - // Assert - expect(result).toEqual(true); -} -); \ No newline at end of file + // Arrange + const password = "12345"; + // Act + const result = isValidPassword(password); + // Assert + expect(result).toEqual(true); +}); \ No newline at end of file From bbbd96cc2bc9b4867e5349db527a0db959f1a2ca Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 19:00:55 +0100 Subject: [PATCH 82/93] In sprint 3 stretch investigate part for the function passwordValidator: - implemented the logic of checking that a password has at least 1 english uppercase letter; - updated the test value checking a password minimal length. - added the presence of english uppercase letter checking test. --- .../4-stretch-investigate/password-validator.js | 11 ++++++++++- .../password-validator.test.js | 15 +++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index b43da707c7..2762d5d137 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -2,7 +2,16 @@ function passwordValidator(password) { if (password.length < 5) { return false; } - return true; + + const upperCaseLettersRegEx = /[A-Z]/; + let hasUpperCaseLetter = false; + + for (let i = 0; i < password.length; i++) { + if (upperCaseLettersRegEx.test(password[i])) { + hasUpperCaseLetter = true; + } + } + return hasUpperCaseLetter; } diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 757cc86a56..07537baa74 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -16,11 +16,18 @@ You must breakdown this problem in order to solve it. Find one test case first a */ const isValidPassword = require("./password-validator"); -test("password has at least 5 characters", () => { +test("Password should have at least 5 characters", () => { // Arrange - const password = "12345"; + const password = "123A"; // Act - const result = isValidPassword(password); + const targetValue = isValidPassword(password); // Assert - expect(result).toEqual(true); + expect(targetValue).toBe(false); +}); + +test("Password should have at least 1 English uppercase letter", () => { + const password = "12345"; + const targetValue = isValidPassword(password); + + expect(targetValue).toBe(false); }); \ No newline at end of file From 63dbae6619c0dc04a0e394ac5f8af32f95cb936b Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 19:14:41 +0100 Subject: [PATCH 83/93] In sprint 3 stretch investigate part for the function passwordValidator: - implemented the logic of checking that a password has at least 1 english lowercase letter; - updated the test value checking a password minimal length and presence of uppercase letter; - added the presence of english lowercase letter checking test; - fixing some variable names. --- .../password-validator.js | 16 +++++++++++----- .../password-validator.test.js | 19 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index 2762d5d137..858629cc63 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -3,15 +3,21 @@ function passwordValidator(password) { return false; } - const upperCaseLettersRegEx = /[A-Z]/; - let hasUpperCaseLetter = false; + const uppercaseLettersRegEx = /[A-Z]/; + const lowercaseLetterRegEx = /[a-z]/; + let hasUppercaseLetter = false; + let hasLowercaseLetter = false for (let i = 0; i < password.length; i++) { - if (upperCaseLettersRegEx.test(password[i])) { - hasUpperCaseLetter = true; + const currentSymbol = password[i]; + if (uppercaseLettersRegEx.test(currentSymbol)) { + hasUppercaseLetter = true; + } + if (lowercaseLetterRegEx.test(currentSymbol)) { + hasLowercaseLetter = true; } } - return hasUpperCaseLetter; + return hasUppercaseLetter && hasLowercaseLetter; } diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 07537baa74..67694327dc 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -18,16 +18,23 @@ const isValidPassword = require("./password-validator"); test("Password should have at least 5 characters", () => { // Arrange - const password = "123A"; + const password = "ABCD"; // Act - const targetValue = isValidPassword(password); + const targetOutput = isValidPassword(password); // Assert - expect(targetValue).toBe(false); + expect(targetOutput).toBe(false); }); test("Password should have at least 1 English uppercase letter", () => { - const password = "12345"; - const targetValue = isValidPassword(password); + const password = "abcde"; + const targetOutput = isValidPassword(password); - expect(targetValue).toBe(false); + expect(targetOutput).toBe(false); +}); + +test("Password should have at least 1 English lowercase letter", () => { + const password = "ABCDE"; + const targetOutput = isValidPassword(password); + + expect(targetOutput).toBe(false); }); \ No newline at end of file From b7c90ec6c8716d288da5d969400566967bddf4da Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 19:21:20 +0100 Subject: [PATCH 84/93] In sprint 3 stretch investigate part for the function passwordValidator: - implemented the logic of checking that a password has at least 1 digit; - updated the test values checking a password minimal length and presence of uppercase and lowercase letters; - added the presence of digit checking test; - fixing some variable names. --- .../4-stretch-investigate/password-validator.js | 11 ++++++++--- .../password-validator.test.js | 15 +++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index 858629cc63..32192d3a61 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -4,20 +4,25 @@ function passwordValidator(password) { } const uppercaseLettersRegEx = /[A-Z]/; - const lowercaseLetterRegEx = /[a-z]/; + const lowercaseLettersRegEx = /[a-z]/; + const digitsRegEx = /[0-9]/; let hasUppercaseLetter = false; let hasLowercaseLetter = false + let hasDigit = false; for (let i = 0; i < password.length; i++) { const currentSymbol = password[i]; if (uppercaseLettersRegEx.test(currentSymbol)) { hasUppercaseLetter = true; } - if (lowercaseLetterRegEx.test(currentSymbol)) { + if (lowercaseLettersRegEx.test(currentSymbol)) { hasLowercaseLetter = true; } + if (digitsRegEx.test(currentSymbol)) { + hasDigit = true; + } } - return hasUppercaseLetter && hasLowercaseLetter; + return hasUppercaseLetter && hasLowercaseLetter && hasDigit; } diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 67694327dc..3feeb0669c 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -18,7 +18,7 @@ const isValidPassword = require("./password-validator"); test("Password should have at least 5 characters", () => { // Arrange - const password = "ABCD"; + const password = "Abc1"; // Act const targetOutput = isValidPassword(password); // Assert @@ -26,15 +26,22 @@ test("Password should have at least 5 characters", () => { }); test("Password should have at least 1 English uppercase letter", () => { - const password = "abcde"; + const password = "abcd1"; const targetOutput = isValidPassword(password); expect(targetOutput).toBe(false); }); test("Password should have at least 1 English lowercase letter", () => { - const password = "ABCDE"; + const password = "ABCD1"; const targetOutput = isValidPassword(password); expect(targetOutput).toBe(false); -}); \ No newline at end of file +}); + +test("Password should have at least 1 digit", () => { + const password = "Abcde"; + const targetOutput = isValidPassword(password); + + expect(targetOutput).toBe(false); +}) \ No newline at end of file From a2bb3920fa757b47300f087b213f7337522cad82 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 19:39:08 +0100 Subject: [PATCH 85/93] In sprint 3 stretch investigate part for the function passwordValidator: - implemented the logic of checking that a password has at least 1 non-alphanumeric symbo ("!", "#", "$", "%", ".", "*", "&"); - updated the test values checking a password minimal length and presence of uppercase, lowercase letters and digits; - added the presence of non-alphanumerical symbols test; - fixed some indents. --- .../password-validator.js | 27 +++++++++++-------- .../password-validator.test.js | 15 ++++++++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index 32192d3a61..13b7d1458e 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -6,23 +6,28 @@ function passwordValidator(password) { const uppercaseLettersRegEx = /[A-Z]/; const lowercaseLettersRegEx = /[a-z]/; const digitsRegEx = /[0-9]/; + const nonAlphanumericSymbolsRegEx = /[!#\$%\.\*&]/; let hasUppercaseLetter = false; let hasLowercaseLetter = false let hasDigit = false; + let hasNonAlphanumericSymbol = false; for (let i = 0; i < password.length; i++) { - const currentSymbol = password[i]; - if (uppercaseLettersRegEx.test(currentSymbol)) { - hasUppercaseLetter = true; - } - if (lowercaseLettersRegEx.test(currentSymbol)) { - hasLowercaseLetter = true; - } - if (digitsRegEx.test(currentSymbol)) { - hasDigit = true; - } + const currentSymbol = password[i]; + if (uppercaseLettersRegEx.test(currentSymbol)) { + hasUppercaseLetter = true; + } + if (lowercaseLettersRegEx.test(currentSymbol)) { + hasLowercaseLetter = true; + } + if (digitsRegEx.test(currentSymbol)) { + hasDigit = true; + } + if (nonAlphanumericSymbolsRegEx.test(currentSymbol)) { + hasNonAlphanumericSymbol = true; + } } - return hasUppercaseLetter && hasLowercaseLetter && hasDigit; + return hasUppercaseLetter && hasLowercaseLetter && hasDigit && hasNonAlphanumericSymbol; } diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 3feeb0669c..15da700191 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -18,7 +18,7 @@ const isValidPassword = require("./password-validator"); test("Password should have at least 5 characters", () => { // Arrange - const password = "Abc1"; + const password = "Ab1$"; // Act const targetOutput = isValidPassword(password); // Assert @@ -26,21 +26,28 @@ test("Password should have at least 5 characters", () => { }); test("Password should have at least 1 English uppercase letter", () => { - const password = "abcd1"; + const password = "abc1#"; const targetOutput = isValidPassword(password); expect(targetOutput).toBe(false); }); test("Password should have at least 1 English lowercase letter", () => { - const password = "ABCD1"; + const password = "ABC1&"; const targetOutput = isValidPassword(password); expect(targetOutput).toBe(false); }); test("Password should have at least 1 digit", () => { - const password = "Abcde"; + const password = "Abcd*"; + const targetOutput = isValidPassword(password); + + expect(targetOutput).toBe(false); +}) + +test("Password should have at least 1 non-alphanumeric symbol ('!', '#', '$', '%', '.', '*', '&')", () => { + const password = "Abcd1"; const targetOutput = isValidPassword(password); expect(targetOutput).toBe(false); From 7a56a8bdc69ddf5d2ec454754165e3a0cc96c6b3 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 20:05:34 +0100 Subject: [PATCH 86/93] In sprint 3 stretch investigate part for the function passwordValidator: - added the second parameter for the function validatePassword -- array of previously used passwords; - implemented the logic of checking that a password is not contained in the previous passwords array; - updated the tests checking a password minimal length and presence of uppercase, lowercase letters and digits; - added the test cheking the previous passwords array contains the given password. --- .../password-validator.js | 12 +++++++++-- .../password-validator.test.js | 20 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/password-validator.js b/Sprint-3/4-stretch-investigate/password-validator.js index 13b7d1458e..9932fbb917 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.js +++ b/Sprint-3/4-stretch-investigate/password-validator.js @@ -1,4 +1,12 @@ -function passwordValidator(password) { +function passwordValidator(password, previousPasswords) { + for (let i = 0; i < previousPasswords.length; i++) { + const currentPreviousPassword = previousPasswords[i]; + + if (password === currentPreviousPassword) { + return false + } + + } if (password.length < 5) { return false; } @@ -30,5 +38,5 @@ function passwordValidator(password) { return hasUppercaseLetter && hasLowercaseLetter && hasDigit && hasNonAlphanumericSymbol; } - +passwordValidator("Bcd1$", ["Bcd1$"]); module.exports = passwordValidator; \ No newline at end of file diff --git a/Sprint-3/4-stretch-investigate/password-validator.test.js b/Sprint-3/4-stretch-investigate/password-validator.test.js index 15da700191..aaa1dce379 100644 --- a/Sprint-3/4-stretch-investigate/password-validator.test.js +++ b/Sprint-3/4-stretch-investigate/password-validator.test.js @@ -15,40 +15,48 @@ To be valid, a password must: You must breakdown this problem in order to solve it. Find one test case first and get that working */ const isValidPassword = require("./password-validator"); +const previousPasswords = ["Bcd1$"]; test("Password should have at least 5 characters", () => { // Arrange const password = "Ab1$"; // Act - const targetOutput = isValidPassword(password); + const targetOutput = isValidPassword(password, previousPasswords); // Assert expect(targetOutput).toBe(false); }); test("Password should have at least 1 English uppercase letter", () => { const password = "abc1#"; - const targetOutput = isValidPassword(password); + const targetOutput = isValidPassword(password, previousPasswords); expect(targetOutput).toBe(false); }); test("Password should have at least 1 English lowercase letter", () => { const password = "ABC1&"; - const targetOutput = isValidPassword(password); + const targetOutput = isValidPassword(password, previousPasswords); expect(targetOutput).toBe(false); }); test("Password should have at least 1 digit", () => { const password = "Abcd*"; - const targetOutput = isValidPassword(password); + const targetOutput = isValidPassword(password, previousPasswords); expect(targetOutput).toBe(false); }) test("Password should have at least 1 non-alphanumeric symbol ('!', '#', '$', '%', '.', '*', '&')", () => { const password = "Abcd1"; - const targetOutput = isValidPassword(password); + const targetOutput = isValidPassword(password, previousPasswords); expect(targetOutput).toBe(false); -}) \ No newline at end of file +}) + +test("Password should not be in previous passwords array", () => { + const password = "Bcd1$"; + const targetOutput = isValidPassword(password, previousPasswords); + + expect(targetOutput).toBe(false); +}); \ No newline at end of file From f4a7b810f2dcc4455e72991070ba48a3f43373ba Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 21:17:34 +0100 Subject: [PATCH 87/93] For card validator project in sprint 3 stretch investigate part: - added file card-validater.js for function validateCard(cardNumber) and function is exported; - added file card-validator.test.js for tests; --- Sprint-3/4-stretch-investigate/card-validator.js | 6 ++++++ Sprint-3/4-stretch-investigate/card-validator.test.js | 1 + 2 files changed, 7 insertions(+) create mode 100644 Sprint-3/4-stretch-investigate/card-validator.js create mode 100644 Sprint-3/4-stretch-investigate/card-validator.test.js diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js new file mode 100644 index 0000000000..a80dbe65bb --- /dev/null +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -0,0 +1,6 @@ +function carValidator(cardNumber) { + +} + + +module.exports = carValidator; \ No newline at end of file diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js new file mode 100644 index 0000000000..2a4c017eb6 --- /dev/null +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -0,0 +1 @@ +const isValidCard = require("./card-validator"); From ee4d225ea39c0ae772f68c8794ee3d0954921e9e Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 21:23:53 +0100 Subject: [PATCH 88/93] For the card validator project in sprint 3 stretch investigate part: - implemented checking the length of the card number logic; - added the test checks the card number length; - fix the typo in the function name. --- Sprint-3/4-stretch-investigate/card-validator.js | 8 +++++--- Sprint-3/4-stretch-investigate/card-validator.test.js | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index a80dbe65bb..193f78e29e 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -1,6 +1,8 @@ -function carValidator(cardNumber) { - +function cardValidator(cardNumber) { + if (cardNumber.length !== 16) { + return false; + } } -module.exports = carValidator; \ No newline at end of file +module.exports = cardValidator; \ No newline at end of file diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js index 2a4c017eb6..4b48057b3c 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.test.js +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -1 +1,8 @@ const isValidCard = require("./card-validator"); + +test("Card number should be 16 characters length.", () => { + const cardNumber = "123412341234123"; + const targetOutput = isValidCard(cardNumber); + + expect(targetOutput).toBe(false); +}) \ No newline at end of file From 6942ad149fa4b50f239e589e75e1a48be4d7ab0b Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 21:37:03 +0100 Subject: [PATCH 89/93] For the card validator project in sprint 3 stretch investigate part: - implemented checking the card number contains non-digit characters logic; - added the test checks the card number contains non-digit characters; --- Sprint-3/4-stretch-investigate/card-validator.js | 8 ++++++++ Sprint-3/4-stretch-investigate/card-validator.test.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index 193f78e29e..baf374e96a 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -1,7 +1,15 @@ function cardValidator(cardNumber) { + const digitsRegEx = /\d/; + if (cardNumber.length !== 16) { return false; } + for (let i = 0; i < cardNumber.length - 1; i++) { + const currentChar = cardNumber[i]; + if (!digitsRegEx.test(cardNumber)) { + return false; + } + } } diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js index 4b48057b3c..3bb452afe7 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.test.js +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -1,8 +1,15 @@ const isValidCard = require("./card-validator"); test("Card number should be 16 characters length.", () => { - const cardNumber = "123412341234123"; + const cardNumber = "0000111122223333444"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); -}) \ No newline at end of file +}) + +test("Card number should not contains non-digit characters", () => { + const cardNumber = "0000111122223333444a"; + const targetOutput = isValidCard(cardNumber); + + expect(targetOutput).toBe(false); +}); \ No newline at end of file From f050c136a8f71d631a556d56d5856574565b36e2 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 21:53:43 +0100 Subject: [PATCH 90/93] For the card validator project in sprint 3 stretch investigate part: - implemented checking the card number digit sum is not less tah 16; - added the test checks the card number digits sum is not less than 16; - fixed logic for the check card number contains only digits; - updated testing card nuber values. --- Sprint-3/4-stretch-investigate/card-validator.js | 10 +++++++--- .../4-stretch-investigate/card-validator.test.js | 13 ++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index baf374e96a..e140e736ee 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -1,16 +1,20 @@ function cardValidator(cardNumber) { const digitsRegEx = /\d/; + let digitsSum = 0; if (cardNumber.length !== 16) { return false; } - for (let i = 0; i < cardNumber.length - 1; i++) { + for (let i = 0; i < cardNumber.length; i++) { const currentChar = cardNumber[i]; - if (!digitsRegEx.test(cardNumber)) { + if (!digitsRegEx.test(currentChar)) { return false; } + digitsSum += Number(currentChar); + } + if (digitsSum < 16) { + return false; } } - module.exports = cardValidator; \ No newline at end of file diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js index 3bb452afe7..eaabb6b751 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.test.js +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -1,15 +1,22 @@ const isValidCard = require("./card-validator"); test("Card number should be 16 characters length.", () => { - const cardNumber = "0000111122223333444"; + const cardNumber = "000011112222333"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); }) test("Card number should not contains non-digit characters", () => { - const cardNumber = "0000111122223333444a"; + const cardNumber = "000011112222333a"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); -}); \ No newline at end of file +}); + +test("Sum of the card number digits should not be less than 16", () => { + const cardNumber = "0000111100001111"; + const targetOutput = isValidCard(cardNumber); + + expect(targetOutput).toBe(false); +}) \ No newline at end of file From 9dd6049577d03918ca1ea026e6d4dc59197db0ed Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 22:06:57 +0100 Subject: [PATCH 91/93] For the card validator project in sprint 3 stretch investigate part: - implemented checking the card number ends in an even digit; - added the test checks the card number ends in an even digit; - updated testing card number values. --- Sprint-3/4-stretch-investigate/card-validator.js | 11 +++++++++-- Sprint-3/4-stretch-investigate/card-validator.test.js | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index e140e736ee..553234b9e9 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -1,10 +1,17 @@ function cardValidator(cardNumber) { + if (cardNumber.length !== 16) { + return false; + } + const digitsRegEx = /\d/; - let digitsSum = 0; + const lastChar = cardNumber[cardNumber - 1]; - if (cardNumber.length !== 16) { + if (digitsRegEx.test(lastChar) && Number(lastChar) % 2 != 0) { return false; } + + let digitsSum = 0; + for (let i = 0; i < cardNumber.length; i++) { const currentChar = cardNumber[i]; if (!digitsRegEx.test(currentChar)) { diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js index eaabb6b751..2f6f2dd1ff 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.test.js +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -1,21 +1,21 @@ const isValidCard = require("./card-validator"); test("Card number should be 16 characters length.", () => { - const cardNumber = "000011112222333"; + const cardNumber = "000044440000222"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); }) test("Card number should not contains non-digit characters", () => { - const cardNumber = "000011112222333a"; + const cardNumber = "000044440000a222"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); }); test("Sum of the card number digits should not be less than 16", () => { - const cardNumber = "0000111100001111"; + const cardNumber = "0000111100002222"; const targetOutput = isValidCard(cardNumber); expect(targetOutput).toBe(false); From b6f2312e752fa8fc1b85c8c5c948e1435c19c12d Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 22:13:13 +0100 Subject: [PATCH 92/93] For the card validator project in sprint 3 stretch investigate part: - fixed checking the card number ends in an even digit; - added the test checks the card number ends in an even digit; --- Sprint-3/4-stretch-investigate/card-validator.js | 3 ++- Sprint-3/4-stretch-investigate/card-validator.test.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index 553234b9e9..4df8595e9a 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -4,7 +4,7 @@ function cardValidator(cardNumber) { } const digitsRegEx = /\d/; - const lastChar = cardNumber[cardNumber - 1]; + const lastChar = cardNumber[cardNumber.length - 1]; if (digitsRegEx.test(lastChar) && Number(lastChar) % 2 != 0) { return false; @@ -22,6 +22,7 @@ function cardValidator(cardNumber) { if (digitsSum < 16) { return false; } + return true; } module.exports = cardValidator; \ No newline at end of file diff --git a/Sprint-3/4-stretch-investigate/card-validator.test.js b/Sprint-3/4-stretch-investigate/card-validator.test.js index 2f6f2dd1ff..42318c1037 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.test.js +++ b/Sprint-3/4-stretch-investigate/card-validator.test.js @@ -18,5 +18,12 @@ test("Sum of the card number digits should not be less than 16", () => { const cardNumber = "0000111100002222"; const targetOutput = isValidCard(cardNumber); + expect(targetOutput).toBe(false); +}) + +test("Card number should ends in even digit", () => { + const cardNumber = "0000444400002221"; + const targetOutput = isValidCard(cardNumber); + expect(targetOutput).toBe(false); }) \ No newline at end of file From a99ff2a381f663f116b5caf542eda33bd13c37a8 Mon Sep 17 00:00:00 2001 From: Nikolai Romanov Date: Sat, 20 Dec 2025 22:21:08 +0100 Subject: [PATCH 93/93] Commented logic of the cardValidator(cardNumber) function in sprint 3 stretch investigate part. --- Sprint-3/4-stretch-investigate/card-validator.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/4-stretch-investigate/card-validator.js b/Sprint-3/4-stretch-investigate/card-validator.js index 4df8595e9a..507ac5e92d 100644 --- a/Sprint-3/4-stretch-investigate/card-validator.js +++ b/Sprint-3/4-stretch-investigate/card-validator.js @@ -1,4 +1,5 @@ function cardValidator(cardNumber) { + //checking the card number length if (cardNumber.length !== 16) { return false; } @@ -6,6 +7,7 @@ function cardValidator(cardNumber) { const digitsRegEx = /\d/; const lastChar = cardNumber[cardNumber.length - 1]; + //checking the card number last character is even digit if (digitsRegEx.test(lastChar) && Number(lastChar) % 2 != 0) { return false; } @@ -14,15 +16,20 @@ function cardValidator(cardNumber) { for (let i = 0; i < cardNumber.length; i++) { const currentChar = cardNumber[i]; + //checking all the card number characters are digits if (!digitsRegEx.test(currentChar)) { return false; } + //summing digits of the card number digitsSum += Number(currentChar); } + //checking sum of digits of the card number if (digitsSum < 16) { return false; } + //returning true if all checks passed return true; } + module.exports = cardValidator; \ No newline at end of file