Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
62f2bc9
corrected the branch to individual folders of sprint-3 implement and …
fayaz551 Mar 7, 2026
5218dc7
Updated isProperFraction implementation and correct tests for negativ…
fayaz551 Mar 8, 2026
4541230
added implementation for invalid cards and removed direct calls from …
fayaz551 Mar 8, 2026
60dd1f1
ensure only valid cards return numbers
fayaz551 Mar 8, 2026
d0b2a26
return "Invalid angle" for angles <0 or >360 and added explicit inval…
fayaz551 Mar 8, 2026
22cbee3
clarify invalid angle tests using valid range 0–360
fayaz551 Mar 8, 2026
9ab2716
fixed the indentation in the function
fayaz551 Mar 8, 2026
a517fe7
fixed the indentation issue
fayaz551 Mar 8, 2026
40bd7ce
categorize cases with descriptive messages
fayaz551 Mar 9, 2026
8c587a2
used shorter descriptive text for test
fayaz551 Mar 9, 2026
560d5c6
implementation to handle boundary angles correctly with test case
fayaz551 Mar 9, 2026
401d8cb
implementation for small valid angle and test case for it
fayaz551 Mar 9, 2026
48cfeba
smallest valid angle
fayaz551 Mar 9, 2026
595de00
updated the test description and function to match task specification
fayaz551 Mar 9, 2026
e21d0fd
tests to include negative numerator and denominator cases
fayaz551 Mar 9, 2026
921a30a
align angle tests and implementation of function with specification o…
fayaz551 Mar 10, 2026
8a9fab6
removed the test written twice
fayaz551 Mar 10, 2026
89c02e7
combined all invalid angles into one test
fayaz551 Mar 10, 2026
b3bbf8a
added another test case (0,0)
fayaz551 Mar 10, 2026
0f7221f
changes description for category 3.
fayaz551 Mar 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
// execute the code to ensure all tests pass.

function getAngleType(angle) {
// TODO: Implement this function
if (angle > 0 && angle < 90) {
return "Acute angle";
}
if (angle === 90) {
return "Right angle";
}
if (angle > 90 && angle < 180) {
return "Obtuse angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle > 180 && angle < 360) {
return "Reflex angle";
}
return "Invalid angle";
Comment thread
cjyuan marked this conversation as resolved.
}

// The line below allows us to load the getAngleType function into tests in other files.
Expand All @@ -35,3 +50,21 @@ function assertEquals(actualOutput, targetOutput) {
// Example: Identify Right Angles
const right = getAngleType(90);
assertEquals(right, "Right angle");

const acute = getAngleType(45);
assertEquals(acute, "Acute angle");

const obtuse = getAngleType(135);
assertEquals(obtuse, "Obtuse angle");

const straight = getAngleType(180);
assertEquals(straight, "Straight angle");

const reflex = getAngleType(270);
assertEquals(reflex, "Reflex angle");

const invalid = getAngleType(-45);
assertEquals(invalid, "Invalid angle");

const invalid2 = getAngleType(361);
assertEquals(invalid2, "Invalid angle");
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if (denominator === 0) {
return false;
}
if (numerator < 0 && denominator < 0) {
return Math.abs(numerator) < Math.abs(denominator);
}
if (numerator < 0 || denominator < 0) {
return false;
}
return numerator < denominator;
}

// The line below allows us to load the isProperFraction function into tests in other files.
Expand All @@ -31,3 +41,10 @@ function assertEquals(actualOutput, targetOutput) {

// Example: 1/2 is a proper fraction
assertEquals(isProperFraction(1, 2), true);
assertEquals(isProperFraction(2, 1), false);
assertEquals(isProperFraction(0, 1), true);
assertEquals(isProperFraction(-1, 2), false);
assertEquals(isProperFraction(1, -2), false);
assertEquals(isProperFraction(-1, -2), false);
Comment thread
cjyuan marked this conversation as resolved.
assertEquals(isProperFraction(3, 4), true);
assertEquals(isProperFraction(4, 3), false);
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

function getCardValue(card) {
// TODO: Implement this function
const rank = card.slice(0, -1);
const suit = card.slice(-1);
if (rank === "A") {
return 11;
}
if (rank === "J" || rank === "Q" || rank === "K") {
return 10;
}
return parseInt(rank);
Comment thread
cjyuan marked this conversation as resolved.
}

// The line below allows us to load the getCardValue function into tests in other files.
Expand Down Expand Up @@ -50,3 +59,12 @@ try {
} catch (e) {}

// What other invalid card cases can you think of?
assertEquals(getCardValue("A"), 11); // Missing suit
try {
getCardValue("11♠"); // Invalid rank
console.error("Error was not thrown for invalid rank");
} catch (e) {}

try { getCardValue("9X"); // Invalid suit
console.error("Error was not thrown for invalid suit");
} catch (e) {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,34 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
});

// Case 2: Right angle
test(`should return "Right angle" when (angle === 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(135)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
});

// Case 4: Straight angle
test(`should return "Straight angle" when (angle === 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 < 0)`, () => {
expect(getAngleType(-1)).toEqual("Invalid angle");
});

test(`should return "Invalid angle" when (angle > 360)`, () => {
expect(getAngleType(361)).toEqual("Invalid angle");
});
Comment thread
cjyuan marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
test(`should return false when denominator is zero`, () => {
expect(isProperFraction(1, 0)).toEqual(false);
});

test(`should return true when numerator is zero and denominator is positive`, () => {
expect(isProperFraction(0, 1)).toEqual(true);
});
Comment thread
cjyuan marked this conversation as resolved.

test(`should return false when numerator is zero and denominator is negative`, () => {
expect(isProperFraction(0, -1)).toEqual(false);
});
Comment thread
cjyuan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,23 @@ test(`Should return 11 when given an ace card`, () => {

// Suggestion: Group the remaining test data into these categories:
// Number Cards (2-10)
test(`Should return the numeric value for number cards`, () => {
expect(getCardValue("2♠")).toEqual(2);
expect(getCardValue("10♠")).toEqual(10);
});
// Face Cards (J, Q, K)
test(`Should return 10 for face cards`, () => {
expect(getCardValue("J♠")).toEqual(10);
expect(getCardValue("Q♠")).toEqual(10);
expect(getCardValue("K♠")).toEqual(10);
});
// Invalid Cards
test(`Should throw an error for invalid cards`, () => {
expect(() => getCardValue("invalid")).toThrow();
expect(() => getCardValue("A")).toThrow(); // Missing suit
expect(() => getCardValue("11♠")).toThrow(); // Invalid rank
expect(() => getCardValue("9X")).toThrow(); // Invalid suit
});

// To learn how to test whether a function throws an error as expected in Jest,
// please refer to the Jest documentation:
Expand Down