Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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,19 @@
// execute the code to ensure all tests pass.

function getAngleType(angle) {
// TODO: Implement this function
if (angle > 0 && angle < 90) {
return "Acute angle";
} else if (angle === 90) {
return "Right angle";
} else if (angle > 90 && angle < 180) {
return "Obtuse angle";
} else if (angle === 180) {
return "Straight angle";
} else if (angle > 180 && angle < 360) {
return "Reflex angle";
} else {
return "Invalid angle";
}
}

// The line below allows us to load the getAngleType function into tests in other files.
Expand All @@ -35,3 +47,18 @@ 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(120);
assertEquals(obtuse, "Obtuse angle");

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

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

const invalid = getAngleType(400);
assertEquals(invalid, "Invalid angle");
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
// execute the code to ensure all tests pass.

function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if ( numerator < denominator && numerator > 0 && denominator > 0) {
return true;
}
return false;
}

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

// Example: 1/2 is a proper fraction
assertEquals(isProperFraction(1, 2), true);
assertEquals(isProperFraction(3, 4), true);
assertEquals(isProperFraction(5, 5), false);
assertEquals(isProperFraction(7, 3), false);
assertEquals(isProperFraction(0, 5), false);
assertEquals(isProperFraction(5, 0), false);
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@
// execute the code to ensure all tests pass.

function getCardValue(card) {
// TODO: Implement this function
if (card === "A♠" || card === "A♥" || card === "A♦" || card === "A♣") {
return 11;
}
if (card === "J♠" || card === "J♥" || card === "J♦" || card === "J♣") {
return 10;
}
if (card === "Q♠" || card === "Q♥" || card === "Q♦" || card === "Q♣") {
return 10;
}
if (card === "K♠" || card === "K♥" || card === "K♦" || card === "K♣") {
return 10;
}
// Check for number cards
const rank = card.slice(0, -1);
const value = parseInt(rank);
if (!isNaN(value) && value >= 2 && value <= 10) {
return value;
}
// If we reach here, the card is invalid
throw new Error("Invalid card format");
}

// The line below allows us to load the getCardValue function into tests in other files.
Expand All @@ -40,6 +59,10 @@ function assertEquals(actualOutput, targetOutput) {
// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
// Examples:
assertEquals(getCardValue("9♠"), 9);
assertEquals(getCardValue("A♠"), 11);
assertEquals(getCardValue("J♠"), 10);
assertEquals(getCardValue("Q♠"), 10);
assertEquals(getCardValue("K♠"), 10);

// Handling invalid cards
try {
Expand Down
Loading