Skip to content

Commit 7cd3556

Browse files
author
Enice-Codes
committed
Implement getAngleType and fix getOrdinalNumber
1 parent 33639ec commit 7cd3556

2 files changed

Lines changed: 13 additions & 40 deletions

File tree

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,23 @@
77
// - "Straight angle" for exactly 180°
88
// - "Reflex angle" for angles greater than 180° and less than 360°
99
// - "Invalid angle" for angles outside the valid range.
10-
1110
// Assumption: The parameter is a valid number. (You do not need to handle non-numeric inputs.)
1211

13-
// Acceptance criteria:
14-
// After you have implemented the function, write tests to cover all the cases, and
15-
// execute the code to ensure all tests pass.
16-
1712
function getAngleType(angle) {
18-
// TODO: Implement this function
13+
if (angle > 0 && angle < 90) {
14+
return "Acute angle";
15+
} else if (angle === 90) {
16+
return "Right angle";
17+
} else if (angle > 90 && angle < 180) {
18+
return "Obtuse angle";
19+
} else if (angle === 180) {
20+
return "Straight angle";
21+
} else if (angle > 180 && angle < 360) {
22+
return "Reflex angle";
23+
} else {
24+
return "Invalid angle";
25+
}
1926
}
2027

2128
// The line below allows us to load the getAngleType function into tests in other files.
22-
// This will be useful in the "rewrite tests with jest" step.
2329
module.exports = getAngleType;
24-
25-
// This helper function is written to make our assertions easier to read.
26-
// If the actual output matches the target output, the test will pass
27-
function assertEquals(actualOutput, targetOutput) {
28-
console.assert(
29-
actualOutput === targetOutput,
30-
`Expected ${actualOutput} to equal ${targetOutput}`
31-
);
32-
}
33-
34-
// TODO: Write tests to cover all cases, including boundary and invalid cases.
35-
// Example: Identify Right Angles
36-
const right = getAngleType(90);
37-
assertEquals(right, "Right angle");

Sprint-3/2-practice-tdd/get-ordinal-number.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< Updated upstream
21
function getOrdinalNumber(num) {
32
const lastTwoDigits = num % 100;
43
const lastDigit = num % 10;
@@ -15,24 +14,6 @@ function getOrdinalNumber(num) {
1514
return `${num}rd`;
1615
} else {
1716
return `${num}th`;
18-
=======
19-
function getOrdinalNumber(number) {
20-
const lastDigit = number % 10;
21-
const lastTwoDigits = number % 100;
22-
23-
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {
24-
return number + "th";
25-
}
26-
27-
if (lastDigit === 1) {
28-
return number + "st";
29-
} else if (lastDigit === 2) {
30-
return number + "nd";
31-
} else if (lastDigit === 3) {
32-
return number + "rd";
33-
} else {
34-
return number + "th";
35-
>>>>>>> Stashed changes
3617
}
3718
}
3819

0 commit comments

Comments
 (0)