-
-
Notifications
You must be signed in to change notification settings - Fork 195
LONDON | ITP_MAY | Mirabel Adom | Module-Structuring-and-Testing-Data | Sprint-3 #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0ed2e6c
c4caa90
0d1d888
9694844
d26acd4
e28e624
d062af5
0a35b17
1c48352
e6e62f8
bc5d62c
387663d
2cefe7e
f257257
7d41ca3
9ca6a34
5f6f46d
c3c5cab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
function getAngleType(angle) { | ||
if (angle === 90) return "Right angle"; | ||
// replace with your completed function from key-implement | ||
if (angle === 180) return "Straight angle"; | ||
if (angle > 0 && angle < 90) return "Acute angle"; | ||
if (angle > 90 && angle < 180) return "Obtuse angle"; | ||
if (angle > 180 && angle < 360) return "Reflex angle"; | ||
|
||
return "Invalid angle"; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// Don't get bogged down in this detail | ||
// Jest uses CommonJS module syntax by default as it's quite old | ||
// We will upgrade our approach to ES6 modules in the next course module, so for now | ||
// We will upgrade our approach to ES6 modules in the next course module, so for now | ||
// we have just written the CommonJS module.exports syntax for you | ||
module.exports = getAngleType; | ||
module.exports = getAngleType; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,21 @@ test("should identify right angle (90°)", () => { | |
// make your test descriptions as clear and readable as possible | ||
|
||
// Case 2: Identify Acute Angles: | ||
// When the angle is less than 90 degrees, | ||
// Then the function should return "Acute angle" | ||
test("should identify acute angle (e.g., 45°)", () => { | ||
expect(getAngleType(45)).toEqual("Acute angle"); | ||
}); | ||
|
||
// Case 3: Identify Obtuse Angles: | ||
// When the angle is greater than 90 degrees and less than 180 degrees, | ||
// Then the function should return "Obtuse angle" | ||
test("should identify obtuse angle (e.g., 120°)", () => { | ||
expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
}); | ||
|
||
// Case 4: Identify Straight Angles: | ||
// When the angle is exactly 180 degrees, | ||
// Then the function should return "Straight angle" | ||
test("should identify straight angle (180°)", () => { | ||
expect(getAngleType(180)).toEqual("Straight angle"); | ||
}); | ||
|
||
// Case 5: Identify Reflex Angles: | ||
// When the angle is greater than 180 degrees and less than 360 degrees, | ||
// Then the function should return "Reflex angle" | ||
test("should identify reflex angle (e.g., 181°)", () => { | ||
expect(getAngleType(181)).toEqual("Reflex angle"); | ||
}); | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also prepare the test like this:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
if ( | ||
typeof numerator !== "number" || | ||
typeof denominator !== "number" || | ||
denominator === 0 | ||
) { | ||
return false; // invalid input | ||
} | ||
|
||
const value = numerator / denominator; | ||
return value > 0 && value < 1; | ||
} | ||
Comment on lines
+2
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In mathematics, -A/B == A/-B == -(A/B), and -A/-B == A/B for any integers A and B (B ≠ 0). So So Consider comparing the absolute value of the numerator and the denominator instead. |
||
|
||
// here's our helper again | ||
function assertEquals(actualOutput, targetOutput) { | ||
console.assert( | ||
actualOutput === targetOutput, | ||
`Expected ${actualOutput} to equal ${targetOutput}` | ||
); | ||
} | ||
|
||
module.exports = isProperFraction; | ||
module.exports = isProperFraction; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
if (typeof card !== "string" || card.length < 2) return 0; | ||
|
||
let rank = card; | ||
|
||
if (card.startsWith("10")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach will also accept values like "100000♣" or "10ABC♣". Consider removing the suit character from |
||
rank = "10"; | ||
} else { | ||
rank = card[0]; | ||
} | ||
|
||
if (rank === "A") return 11; | ||
if (["K", "Q", "J"].includes(rank)) return 10; | ||
|
||
const numberValue = Number(rank); | ||
if (!isNaN(numberValue)) return numberValue; | ||
|
||
return 0; | ||
} | ||
module.exports = getCardValue; | ||
module.exports = getCardValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you implementation pass the tests in this script?