From dd85a1dc89466c4579c41d8d7f541503531a908b Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 11:39:56 +0000 Subject: [PATCH 1/5] checking to see the output of count using terminal --- Sprint-1/1-key-exercises/1-count.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..bf16e5b22 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -2,5 +2,6 @@ let count = 0; count = count + 1; +console.log(count); // Line 1 is a variable declaration, creating the count variable with an initial value of 0 -// Describe what line 3 is doing, in particular focus on what = is doing +// Describe what line 3 is doing, in particular focus on what = is doing \ No newline at end of file From c7ddaed669e179af83505419fa2b554e9704b8ae Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 12:01:45 +0000 Subject: [PATCH 2/5] Updating the script with comments detailing my understanding of the script --- Sprint-1/1-key-exercises/1-count.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index bf16e5b22..e1ca0860c 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,4 +4,8 @@ count = count + 1; console.log(count); // Line 1 is a variable declaration, creating the count variable with an initial value of 0 -// Describe what line 3 is doing, in particular focus on what = is doing \ No newline at end of file +// Describe what line 3 is doing, in particular focus on what = is doing +// The '=' assignment operator. It assigns the value on the right hand side to the variable on the left. +// The variable 'count' is initially assigned the value of 0. +// And the result is assigned back to count. +// This mean 'count; is updated each time this line runs. \ No newline at end of file From 3685fe5186e24471c9cb860d4ef568400dc2a1a6 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 19 Feb 2026 22:09:06 +0000 Subject: [PATCH 3/5] :wq EnterEsc :wq EnterEsc :wq Esc :wq Enter :q! Enter --- .../1-get-angle-type.test.js | 26 +++++++++++++ .../2-is-proper-fraction.test.js | 38 ++++++++++++++++++- .../3-get-card-value.test.js | 31 +++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d777f348d..9a754e26c 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -14,7 +14,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test('should return "Right angle" when angle is 90', () => { + expect(getAngleType(90)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles +test('should return "Obtuse angle" when (90 < angle < 180)', () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(120)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}) + // Case 4: Straight angle +test('should return "Straight angle" when angle is 180', () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}) + // Case 5: Reflex angles +test('should return "Reflex angle" when (180 < angle < 360)', () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(270)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}) + // Case 6: Invalid angles +test('should return "Invalid angle" when angle is outside valid range', () => { + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(-10)).toEqual("Invalid angle"); + expect(getAngleType(720)).toEqual("Invalid angle"); +}) \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 7f087b2ba..9f2e06a7e 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -4,7 +4,43 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. -// Special case: numerator is zero +// Special case: denominator is zero test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +// Numerator is zero +test(`should return true when numerator is zero and denominator is non-zero`, () => { + expect(isProperFraction(0, 1)).toEqual(true); +}); + +//Proper fractions +test("should return true for proper fractions", () => { + expect(isProperFraction(1,2)).toEqual(true); + expect(isProperFraction(2,5)).toEqual(true); +}) + +//Equal Numerator and Denominator +test("should return false when numerator equals denominator", () => { + expect(isProperFraction(2,2)).toEqual(false); +}) + +//Improper fractions +test("should return false for improper fractions", () => { + expect(isProperFraction(5,3)).toEqual(false); +}) + +//Negative numerator +test("should return true when numerator is negative but absolute value is smaller", () => { + expect(isProperFraction(-1, 3)).toEqual(true); +}) + +//Negative denominator +test("should return true when denominator is negative but absolute value is larger", () => { + expect(isProperFraction(1, -3)).toEqual(true); +}) + +//Both Negative +test("should return true when both numerator and denominator are negative and proper", () => { + expect(isProperFraction(-2, -5)).toEqual(true); +}) \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index cf7f9dae2..934a3ad3a 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -9,6 +9,37 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Number Cards +test("should return correct numeric value for number cards", () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("7♦")).toEqual(7); + expect(getCardValue("10♣")).toEqual(10); +}) + +// Case 3: Face Cards +test("should return 10 for face cards", () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♥")).toEqual(10); + expect(getCardValue("K♦")).toEqual(10); +}) + +// Case 4: Invalid Cards +test("should throw error for invalid suit", () => { + expect(() => getCardValue("A?")).toThrow(); +}) + +test("should throw error for invalid rank", () => { + expect(() => getCardValue("1♠")).toThrow(); +}); + +test("should throw error for missing suit", () => { + expect(() => getCardValue("A")).toThrow(); +}); + +test("should throw error for completely invalid string", () => { + expect(() => getCardValue("invalid")).toThrow(); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 662a7eb9c6e2527cea248ba4cf08e505bed395aa Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 19 Feb 2026 22:28:14 +0000 Subject: [PATCH 4/5] Complete Sprint 3: 1-implement-and-rewrite-tests --- .../implement/1-get-angle-type.js | 50 +++++++++++++++-- .../implement/2-is-proper-fraction.js | 27 +++++++++- .../implement/3-get-card-value.js | 53 +++++++++++++++++-- .../1-get-angle-type.test.js | 2 +- .../2-is-proper-fraction.test.js | 16 +++--- .../3-get-card-value.test.js | 1 - 6 files changed, 132 insertions(+), 17 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e..bdad818a5 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -15,7 +15,27 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + if (angle <= 0 || angle >= 360) { + return "Invalid angle"; + } + + if (angle === 90) { + return "Right angle"; + } + + if (angle > 0 && angle < 90) { + return "Acute angle"; + } + + if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } + + if (angle === 180) { + return "Straight angle"; + } + + return "Reflex angle"; } // The line below allows us to load the getAngleType function into tests in other files. @@ -33,5 +53,29 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles -const right = getAngleType(90); -assertEquals(right, "Right angle"); +// Acute Angles: +assertEquals(getAngleType(1), "Acute angle"); +assertEquals(getAngleType(45), "Acute angle"); +assertEquals(getAngleType(89), "Acute angle"); + +//Right Angles: +assertEquals(getAngleType(90), "Right angle"); + +//Obtuse Angles: +assertEquals(getAngleType(91), "Obtuse angle"); +assertEquals(getAngleType(120), "Obtuse angle"); +assertEquals(getAngleType(179), "Obtuse angle"); + +//Straight Angles: +assertEquals(getAngleType(180), "Straight angle"); + +//Reflex Angles: +assertEquals(getAngleType(181), "Reflex angle"); +assertEquals(getAngleType(270), "Reflex angle"); +assertEquals(getAngleType(359), "Reflex angle"); + +// Invalid Angles +assertEquals(getAngleType(0), "Invalid angle"); +assertEquals(getAngleType(360), "Invalid angle"); +assertEquals(getAngleType(-10), "Invalid angle"); +assertEquals(getAngleType(720), "Invalid angle"); \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 970cb9b64..c9fd7863d 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -11,7 +11,8 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (denominator === 0) return false; + return Math.abs(numerator) < Math.abs(denominator); } // The line below allows us to load the isProperFraction function into tests in other files. @@ -30,4 +31,28 @@ function assertEquals(actualOutput, targetOutput) { // What combinations of numerators and denominators should you test? // Example: 1/2 is a proper fraction + +//Proper Fractions assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(2, 5), true); + +//Equal values (Not proper fractions) +assertEquals(isProperFraction(2, 2), false); + +//Improper Fractions +assertEquals(isProperFraction(5, 3), false); + +//Negative Numerator +assertEquals(isProperFraction(-1, 3), true); + +//Negative Denominator +assertEquals(isProperFraction(1, -3), true); + +//Both Negative Numerator and Denominator +assertEquals(isProperFraction(-2, -5), true); + +//Zero Numerator +assertEquals(isProperFraction(0, 5), true); + +//Zero Denominator +assertEquals(isProperFraction(1, 0), false); \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index c7559e787..bd557220a 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -22,8 +22,29 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function -} + if (typeof card !== "string" || card.length < 2){ + throw new Error("Invalid card"); + } + + const suits = ["♠", "♥", "♦", "♣"]; + const suit = card.slice(-1); + const rank = card.slice(0,-1); + + if (!suits.includes(suit)) { + throw new Error("Invalid card"); + } + + if (rank === "A") return 11; + if (["J", "Q", "K"].includes(rank)) return 10; + + const numericValue = Number(rank); + + if (numericValue >= 2 && numericValue <= 10) { + return numericValue; + } + + throw new Error("Invalid card"); + } // The line below allows us to load the getCardValue function into tests in other files. // This will be useful in the "rewrite tests with jest" step. @@ -41,12 +62,38 @@ function assertEquals(actualOutput, targetOutput) { // Examples: assertEquals(getCardValue("9♠"), 9); +// Ace +assertEquals(getCardValue("A♠"), 11); + +// Face cards +assertEquals(getCardValue("J♥"), 10); +assertEquals(getCardValue("Q♦"), 10); +assertEquals(getCardValue("K♣"), 10); + +// Numeric Cards +assertEquals(getCardValue("2♠"), 2); +assertEquals(getCardValue("10♦"), 10); + // Handling invalid cards try { getCardValue("invalid"); // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); -} catch (e) {} +} catch (e) { + console.log("Correctly threw error for invalid card"); +} // What other invalid card cases can you think of? + +// Invliad suit +try { getCardValue("A?"); console.error("No error thrown"); } catch(e) {} + +// Invalid rank +try { getCardValue("1♠"); console.error("No error thrown"); } catch(e) {} + +// Missing suit +try { getCardValue("A"); console.error("No error thrown"); } catch(e) {} + +// Extra characters +try { getCardValue("AAA♠"); console.error("No error thrown"); } catch(e) {} \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 9a754e26c..eec82a570 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -13,7 +13,7 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { expect(getAngleType(89)).toEqual("Acute angle"); }); -// Case 2: Right angle +// Case 2: Right angles test('should return "Right angle" when angle is 90', () => { expect(getAngleType(90)).toEqual("Right angle"); }); diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 9f2e06a7e..e1afbeff4 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -4,43 +4,43 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. -// Special case: denominator is zero +// Case 1: Special case: denominator is zero test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); -// Numerator is zero +// Case 2: Numerator is zero test(`should return true when numerator is zero and denominator is non-zero`, () => { expect(isProperFraction(0, 1)).toEqual(true); }); -//Proper fractions +// Case 3: Proper fractions test("should return true for proper fractions", () => { expect(isProperFraction(1,2)).toEqual(true); expect(isProperFraction(2,5)).toEqual(true); }) -//Equal Numerator and Denominator +// Case 4: Equal Numerator and Denominator test("should return false when numerator equals denominator", () => { expect(isProperFraction(2,2)).toEqual(false); }) -//Improper fractions +// Case 5: Improper fractions test("should return false for improper fractions", () => { expect(isProperFraction(5,3)).toEqual(false); }) -//Negative numerator +// Case 6: Negative numerator test("should return true when numerator is negative but absolute value is smaller", () => { expect(isProperFraction(-1, 3)).toEqual(true); }) -//Negative denominator +// Case 7: Negative denominator test("should return true when denominator is negative but absolute value is larger", () => { expect(isProperFraction(1, -3)).toEqual(true); }) -//Both Negative +// Case 8: Both Negative test("should return true when both numerator and denominator are negative and proper", () => { expect(isProperFraction(-2, -5)).toEqual(true); }) \ No newline at end of file diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 934a3ad3a..e42de89e9 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -39,7 +39,6 @@ test("should throw error for missing suit", () => { test("should throw error for completely invalid string", () => { expect(() => getCardValue("invalid")).toThrow(); }); - // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 3bec4b0a629c6fe4e97dcf876a40f980cbf87eaf Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 22 Feb 2026 20:28:53 +0000 Subject: [PATCH 5/5] Remove Sprint-1 1-count.js from this branch --- Sprint-1/1-key-exercises/1-count.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index e1ca0860c..117bcb2b6 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -2,10 +2,5 @@ let count = 0; count = count + 1; -console.log(count); // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing -// The '=' assignment operator. It assigns the value on the right hand side to the variable on the left. -// The variable 'count' is initially assigned the value of 0. -// And the result is assigned back to count. -// This mean 'count; is updated each time this line runs. \ No newline at end of file