Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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 @@ -8,23 +8,17 @@
// 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 false
}
if((Math.abs(numerator))<denominator){
return true
}
if (numerator > denominator) {
if (denominator === 0) {
return false;
}
if (denominator === 0){
return false
if (numerator < denominator && numerator > -denominator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In math, 2/-3 is equal to -2/3, and -2/-3 = 2/3.
So ideally isProperFraction(2, -3) and isProperFraction(-2, -3) should also true.

Suggestion: Look up the definition of proper fraction.

return true;
} else {
return false;
}
}


// The line below allows us to load the isProperFraction function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
module.exports = isProperFraction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ function getCardValue(card) {
else {
return "Invalid card rank."
}
// for (let i=1; i<10; i++){
// if (i==5){
// return rank === "5"
// }
// }

}

// The line below allows us to load the getCardValue function into tests in other files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ test("should return true for a proper fraction", () => {
});

// Case 2: Identify Improper Fractions:
test("should return false for numerato>denominator",()=>{
test("should return false for numerator>denominator",()=>{
expect(isProperFraction(5, 2)).toEqual(false);
} );

// Case 3: Identify Negative Fractions:
test ("should return true for negative Fraction",()=>{
expect(isProperFraction(-4,7)).toEqual(true);
test("should return true when the fraction is negative but proper (numerator smaller than denominator in absolute value)", () => {
expect(isProperFraction(-4, 7)).toEqual(true);
});


test("should return false when the numerator is negative and greater in absolute value than the denominator", () => {
expect(isProperFraction(-3, 2)).toEqual(false);
});

// Case 4: Identify Equal Numerator and Denominator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
// This statement loads the getCardValue function you wrote in the implement directory.
// We will use the same function, but write tests for it using Jest in this file.
const getCardValue = require("../implement/3-get-card-value");

test("should return 11 for Ace of Spades", () => {
const aceofSpades = getCardValue("A♠");
expect(aceofSpades).toEqual(11);
// Case 1: Handle Number Cards (2-10)
test("should return the value of number cards (2-10)", () => {
expect(getCardValue("2♣")).toEqual(2);
expect(getCardValue("5♥")).toEqual(5);
expect(getCardValue("10♦")).toEqual(10);
});

// Case 2: Handle Number Cards (2-10):
test ("should return a 5 for the card with rank of 5 like(5♥) ",()=>{
const fiveofHearts = getCardValue("5♥");
expect(fiveofHearts).toEqual(5);
// Case 2: Handle Face Cards (J, Q, K)
test("should return 10 for face cards (J, Q, K)", () => {
expect(getCardValue("J♠")).toEqual(10);
expect(getCardValue("Q♣")).toEqual(10);
expect(getCardValue("K♦")).toEqual(10);
});

// Case 3: Handle Ace (A)
test("should return 11 for Ace cards", () => {
expect(getCardValue("A♠")).toEqual(11);
expect(getCardValue("A♣")).toEqual(11);
});

})
// Case 3: Handle Face Cards (J, Q, K):
test("shoild return 10 fore the faced cart like king(K♦) and queen (Q♣)")
const kingCard =getCardValue("K♦");
const queenCard= getCardValue("Q♣");
expect(kingCard).toEqual(10);
expect (queenCard).toEqual(10);
// Case 4: Handle Ace (A):
test("should return 11 for Ace of Spades", () => {
const aceofSpades = getCardValue("A♣");
expect(aceofSpades).toEqual(11);
// Case 4: Handle Invalid Cards
test("should return 'Invalid card rank.' for invalid cards", () => {
expect(getCardValue("z♣")).toEqual("Invalid card rank.");
expect(getCardValue("11♠")).toEqual("Invalid card rank.");
});
// Case 5: Handle Invalid Cards:
test ("should return invalid card rank for invalid inputs like(z♣)",()=>{
const invalidCard= getCardValue("z♣");
expect(invalidCard).toEqual("Invalid card rank.");
});