Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
529ed10
Implement the condition to execute and determines acute angle
Tobias-Amaechina Jun 29, 2026
10fee33
Wrote test to check for acute angle lower refernce
Tobias-Amaechina Jun 29, 2026
a593587
Wrote test to check acute angle in the mid range
Tobias-Amaechina Jun 29, 2026
e97765d
Wrote test for the upper limit acute angle
Tobias-Amaechina Jun 29, 2026
4d173e0
Implemented a function to check if angle is right angle
Tobias-Amaechina Jun 29, 2026
f1e2785
wrote a test that check right angle
Tobias-Amaechina Jun 29, 2026
0d0ea09
Implements condition to execute Obtuse angle
Tobias-Amaechina Jun 29, 2026
cd0ed46
wrote test to check obtuse angle just above right angle
Tobias-Amaechina Jun 29, 2026
800eb91
Wrote a test to check mid range obtuse angle
Tobias-Amaechina Jun 29, 2026
e7d9706
wrote test for upper limit obtuse angle
Tobias-Amaechina Jun 29, 2026
49b67a4
Implemented statement to execute straight angle
Tobias-Amaechina Jun 29, 2026
3f44e88
Wrote a test to check for straight angle
Tobias-Amaechina Jun 29, 2026
4533447
Implemented statement to execute reflex angle condition
Tobias-Amaechina Jun 29, 2026
4e66775
Wrote test to check the lower limit of Reflex angle
Tobias-Amaechina Jun 29, 2026
8c83316
Wrote test to check mid range reflex angle
Tobias-Amaechina Jun 29, 2026
142a377
Wrote test to check the upperlimit of reflex angle
Tobias-Amaechina Jun 29, 2026
d9af0e9
Implemented statement to execute lower invalid angle
Tobias-Amaechina Jun 29, 2026
06da082
Wrote test to check lower invalid angle
Tobias-Amaechina Jun 29, 2026
792abfe
Implemented statement to execute upper limit invalid angle
Tobias-Amaechina Jun 29, 2026
7c1314f
Wrote a test to check when angle is zero
Tobias-Amaechina Jun 29, 2026
b63764b
Wrote a test to check for angle 360
Tobias-Amaechina Jun 29, 2026
1580dbf
Wrote a test to check when angle is over 360
Tobias-Amaechina Jun 29, 2026
925c0c9
print a statement to say that all test passed
Tobias-Amaechina Jun 29, 2026
ce30492
Implement the statement to execute the logic
Tobias-Amaechina Jul 1, 2026
74c61b0
wrote a test to check improper fraction
Tobias-Amaechina Jul 1, 2026
cf6edc1
wrote a test to check when numerotor is zero and denominator 5
Tobias-Amaechina Jul 1, 2026
7b66cae
Wrote a test for Improper fraction with denomintor having zero value
Tobias-Amaechina Jul 1, 2026
4b4e850
Wrote a test for proper fraction when numerator is negative and denom…
Tobias-Amaechina Jul 1, 2026
730a4dd
wrote a test for proper fraction with denominator -ve and numerator +ve
Tobias-Amaechina Jul 1, 2026
06966ef
wrote a tesch for a proper fraction with both nuerator and denominto…
Tobias-Amaechina Jul 1, 2026
6195e24
wrote a test to check when both numerator and denominator are both …
Tobias-Amaechina Jul 1, 2026
7c27db4
printed a message on console to assertain that all test has passed
Tobias-Amaechina Jul 1, 2026
8845db2
validating the card format
Tobias-Amaechina Jul 2, 2026
b877904
declared variable called validSuits and assign arrays of suits to it
Tobias-Amaechina Jul 2, 2026
0162639
Declaring a suit variable by extrating the last part of any card and …
Tobias-Amaechina Jul 2, 2026
e08a340
Declaring the rank valiable and assign the rank valuefrom the card u…
Tobias-Amaechina Jul 2, 2026
7ba9bb8
validates the extrated suits of card using .includes method
Tobias-Amaechina Jul 2, 2026
a0803b8
Declared variable validRanks and assign arrays of valid ranks to it
Tobias-Amaechina Jul 2, 2026
d271f56
Validates extrated ranks from the arrays and throw an error if any is…
Tobias-Amaechina Jul 2, 2026
f04f769
validate the ranks with the conditions and return the correct values
Tobias-Amaechina Jul 2, 2026
658833c
Wrote test to check and output 11
Tobias-Amaechina Jul 3, 2026
fce428b
wrote a test to return the numeric value of the card
Tobias-Amaechina Jul 3, 2026
1250425
Wrote a test to check for when a rank contains J and out put 10
Tobias-Amaechina Jul 3, 2026
e580525
Wrote a test to check if the rank contains Q and output 10
Tobias-Amaechina Jul 3, 2026
4e86a32
Wrote a test to check if the rank contains K and output 10
Tobias-Amaechina Jul 3, 2026
98cbf1d
Wrote a test to check if a card is a number and return it's numeric …
Tobias-Amaechina Jul 3, 2026
07c23ca
wrote a try catch test for an invalid suit
Tobias-Amaechina Jul 3, 2026
3cff182
testing and invalid rank
Tobias-Amaechina Jul 3, 2026
39113c2
wrote try catch for missing suit
Tobias-Amaechina Jul 3, 2026
240eea3
Wrote a code that handles empty string errors
Tobias-Amaechina Jul 3, 2026
f6fc635
Wrote code to handle non-string input
Tobias-Amaechina Jul 3, 2026
62589be
wrote code to handle extra character errors
Tobias-Amaechina Jul 3, 2026
da5d8a3
Wrote the test suite for case 2 to check for right angle
Tobias-Amaechina Jul 5, 2026
80dcb0f
Wrote a test suit for Case 3 Obtuse angle
Tobias-Amaechina Jul 5, 2026
d5646de
Wrote a test suit to check case 4 straight line
Tobias-Amaechina Jul 5, 2026
7afc721
Wrote a test suit to check for reflex angle case 5
Tobias-Amaechina Jul 5, 2026
0942061
wrote a test suit to chek for an invalid angles
Tobias-Amaechina Jul 5, 2026
b850940
Wrote a test suit to check for special case when numerator is 0
Tobias-Amaechina Jul 5, 2026
3ae5e6c
Wrote a test suit to check for special cases when numerator & denomin…
Tobias-Amaechina Jul 5, 2026
5241806
Wrote a test suit to check for when the numerator is greater than den…
Tobias-Amaechina Jul 5, 2026
0acbb55
wrote a test suit to check for when denominator is greater than the…
Tobias-Amaechina Jul 5, 2026
6c3c897
Wrote a test suit to check for when numerator is negative and denomi…
Tobias-Amaechina Jul 5, 2026
bd92f23
wrote a test suit to check for when numerator is positive and denom…
Tobias-Amaechina Jul 5, 2026
adbdbf5
Wrote a test suit to check for when both denominator and numerators …
Tobias-Amaechina Jul 5, 2026
7e4bc9b
Wrote a test suite to return a card numeric value in this card 2
Tobias-Amaechina Jul 6, 2026
bbe10f9
Rewite test for getcardValue
Tobias-Amaechina Jul 6, 2026
7695832
rewrote test to check and print the numeric value of card when 4
Tobias-Amaechina Jul 6, 2026
9f51172
rewrote test to check and print the numeric value of card when 5
Tobias-Amaechina Jul 6, 2026
a257497
rewrote test to check and print the numeric value of card when 6
Tobias-Amaechina Jul 6, 2026
e23e51d
rewrote test to check and print the numeric value of card when 7
Tobias-Amaechina Jul 6, 2026
c5ccd5d
rewrote test to check and print the numeric value of card when 8
Tobias-Amaechina Jul 6, 2026
be6cdbc
rewrote test to check and print the numeric value of card when 9
Tobias-Amaechina Jul 6, 2026
84ffbfe
rewrote test to check and print the numeric value of card when 10
Tobias-Amaechina Jul 6, 2026
41b3b3b
rewrote test to check and print the numeric 10 when given a J card
Tobias-Amaechina Jul 6, 2026
168aabe
rewrote test to check and print the numeric 10 when given a Q card
Tobias-Amaechina Jul 6, 2026
cf96c14
rewrote test to check and print the numeric 10 when given a K card
Tobias-Amaechina Jul 6, 2026
32055e1
rewrote test to check an invalid card when rank is numeric 1
Tobias-Amaechina Jul 6, 2026
55b402f
rewrote test to check an invalid suit
Tobias-Amaechina Jul 6, 2026
52878f1
rewrote test to check an invalid card
Tobias-Amaechina Jul 6, 2026
fb62cf4
rewrote test to check an invalid card format
Tobias-Amaechina Jul 6, 2026
6ae0956
Update Jest tests for getCardValue
Tobias-Amaechina Jul 6, 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 @@ -14,7 +14,26 @@
// After you have implemented the function, write tests to cover all the cases, and
// execute the code to ensure all tests pass.

function getAngleType(angle) {
function getAngleType(angle) {

if (angle > 0 && angle < 90) {
return "Acute angle";//Implement condition to execute acute angle
}else if (angle === 90){
return "Right angle";// checking for 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 if (angle <=0){
return "Invalid angle"
} else {
// Anything else must be 360 or greater than 360
return "Invalid angle";
}


// TODO: Implement this function
}

Expand All @@ -32,6 +51,41 @@ function assertEquals(actualOutput, targetOutput) {
}

// TODO: Write tests to cover all cases, including boundary and invalid cases.
// Example: Identify Right Angles
const right = getAngleType(90);
// test acute angle
const acute = getAngleType(1);// Test just above zero
assertEquals(acute, "Acute angle");
const acute2 = getAngleType(45); // Test acute angle just at the middle
assertEquals(acute2, "Acute angle");
const acute3 = getAngleType(89.9); // Test just above zero
assertEquals(acute3, "Acute angle");
const right = getAngleType(90);// Testing for right angle
assertEquals(right, "Right angle");
//testing for obtuse angles
const obtuse = getAngleType(90.1);
assertEquals(obtuse, "Obtuse angle");
const obtuse1 = getAngleType(136);
assertEquals(obtuse1,"Obtuse angle");
const obtuse2 = getAngleType(179.9);
assertEquals(obtuse2,"Obtuse angle");
// Testing for a straight angle
const straight = getAngleType(180);
assertEquals(straight,"Straight angle");
//Testing for Reflex angles
const reflex = getAngleType(180.1);
assertEquals(reflex,"Reflex angle");// testing for the lower limit reflex angle
const reflex1 = getAngleType(270);
assertEquals(reflex1,"Reflex angle");
const reflex2 = getAngleType(359.9)// testing upper limit of reflex angle
assertEquals(reflex2,"Reflex angle");
//Testing invalid lower angle numbers
const lessThanOrEqualToZero = getAngleType(-1);
assertEquals(lessThanOrEqualToZero,"Invalid angle");
const equalToZero = getAngleType(0);
assertEquals(equalToZero, "Invalid angle");// Testing for when angle is zero
const equal360 = getAngleType(360); // Testing whn angle is 360
assertEquals(equal360,"Invalid angle");
const over360 = getAngleType(360.1); // Testing when angle is over 360
assertEquals(over360, "Invalid angle");

console.log("All test passed!");

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

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

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

// Example: 1/2 is a proper fraction
assertEquals(isProperFraction(1, 2), true);
// Write a test for 2/1, which is not a proper fraction
assertEquals(isProperFraction(2, 1), false);
// Write a test for 0/5, which is a proper fraction
assertEquals(isProperFraction(0, 5), true);
// Write a test for 5/0, which is not a proper fraction (denominator cannot be zero)
assertEquals(isProperFraction(5, 0), false);
// Write a test for -1/2, which is a proper fraction
assertEquals(isProperFraction(-1, 2), true);
// Write a test for 1/-2, which is a proper fraction
assertEquals(isProperFraction(1, -2), true);
// Write a test for -3/-4, which is a proper fraction
assertEquals(isProperFraction(-3, -4), true);
// Write a test for 3/3, which is not a proper fraction
assertEquals(isProperFraction(3, 3), false);
console.log("All tests passed!");



Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@
// execute the code to ensure all tests pass.

function getCardValue(card) {
if (typeof card !== "string" || card.length < 2) {
throw new Error("Invalid card format");
}
const validSuits = ["♠", "♥", "♦", "♣"];
const suit = card.slice(-1); // getting the last character as suit
const rank = card.slice(0, -1); // getting the rest as rank

if (!validSuits.includes(suit)) {
throw new Error("Invalid suit");
}

const validRanks = [
"A",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"J",
"Q",
"K",
];
if (!validRanks.includes(rank)) {
throw new Error("Invalid rank");
}

if (rank === "A") return 11;
if (["J", "Q", "K"].includes(rank)) return 10;

return Number(rank);

// TODO: Implement this function
}

Expand All @@ -40,6 +75,12 @@ 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("10♦"), 10);
assertEquals(getCardValue("J♣"), 10);
assertEquals(getCardValue("Q♥"), 10);
assertEquals(getCardValue("K♦"), 10);
assertEquals(getCardValue("2♣"), 2);

// Handling invalid cards
try {
Expand All @@ -52,3 +93,46 @@ try {
}

// What other invalid card cases can you think of?
try {
getCardValue("A?"); // invalid suit

// This line will not be reached if an error is thrown as expected
console.error("Error was not thrown for invalid card 😢");
} catch (e) {
console.log("Error thrown for invalid card 🎉");
}
try {
getCardValue("1♠"); // invalid rank

// This line will not be reached if an error is thrown as expected
console.error("Error was not thrown for invalid card 😢");
} catch (e) {
console.log("Error thrown for invalid rank");
}
try {
getCardValue("A"); // invalid rank

// This line will not be reached if an error is thrown as expected
console.error("Error was not thrown for invalid card 😢");
} catch (e) {
console.log("Error thrown for missing suit");
}

try {
getCardValue("");
console.error("Error was not thrown for empty string 😢");
} catch (e) {
console.log("Error thrown for empty string ");
}
try {
getCardValue(123);
console.error("Error was not thrown for non-string input 😢");
} catch (e) {
console.log("Error thrown for non-string input ");
}
try {
getCardValue("A♠♠");
console.error("Error was not thrown for extra characters 😢");
} catch (e) {
console.log("Error thrown for extra characters ");
}
Loading
Loading