Skip to content

Commit 3f9f362

Browse files
exercises
1 parent 244451e commit 3f9f362

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

Sprint-1/2-mandatory-errors/4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
2+
const 24hourClockTime = "08:53";

Sprint-2/5-stretch-extend/format-time.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ console.assert(
2525
`current output: ${currentOutput2}, target output: ${targetOutput2}`
2626
);
2727

28-
console.log formatAs12HourClock("14:00"); // 2pm
28+
console.log formatAs12HourClock("14:00"); // should return "2:00 pm"

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
// After you have implemented the function, write tests to cover all the cases, and
1515
// execute the code to ensure all tests pass.
1616

17-
function getAngleType(angle) {
17+
//function getAngleType(angle) {
1818
// TODO: Implement this function
19+
//}
20+
21+
function getAngleType(angle) {
22+
if (angle > 0 && angle < 90) return 'Acute angle'; // Angles between 0 and 90
23+
if (angle === 90) return 'Right angle'; // Exactly 90 degrees
24+
if (angle > 90 && angle < 180) return 'Obtuse angle'; // Angles between 90 and 180
25+
return 'Invalid angle'; // For angles that don't fit any type
1926
}
2027

28+
2129
// The line below allows us to load the getAngleType function into tests in other files.
2230
// This will be useful in the "rewrite tests with jest" step.
2331
module.exports = getAngleType;

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
// After you have implemented the function, write tests to cover all the cases, and
1111
// execute the code to ensure all tests pass.
1212

13-
function isProperFraction(numerator, denominator) {
13+
//function isProperFraction(numerator, denominator) {
1414
// TODO: Implement this function
15+
//}
16+
function isProperFraction(numerator, denominator) {
17+
if (denominator === 0) return false; // Handle zero denominator case
18+
return numerator < denominator; // Normal fraction check
1519
}
1620

21+
1722
// The line below allows us to load the isProperFraction function into tests in other files.
1823
// This will be useful in the "rewrite tests with jest" step.
1924
module.exports = isProperFraction;

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
// After you have implemented the function, write tests to cover all the cases, and
2222
// execute the code to ensure all tests pass.
2323

24-
function getCardValue(card) {
24+
//function getCardValue(card) {
2525
// TODO: Implement this function
26+
//}
27+
28+
function getCardValue(card) {
29+
if (card === 'A♠' || card === 'A♥' || card === 'A♦' || card === 'A♣') return 11; // Ace value
30+
// handle other card values...
31+
return undefined; // Handle invalid cards
2632
}
2733

34+
2835
// The line below allows us to load the getCardValue function into tests in other files.
2936
// This will be useful in the "rewrite tests with jest" step.
3037
module.exports = getCardValue;
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
function getOrdinalNumber(num) {
2-
return "1st";
1+
//function getOrdinalNumber(num) {
2+
// return "1st";
3+
//}
4+
5+
//module.exports = getOrdinalNumber;
6+
7+
function getOrdinalNumber(n) {
8+
const suffix = (n % 10 === 1 && n % 100 !== 11) ? 'st' :
9+
(n % 10 === 2 && n % 100 !== 12) ? 'nd' :
10+
(n % 10 === 3 && n % 100 !== 13) ? 'rd' : 'th';
11+
return `${n}${suffix}`;
312
}
413

514
module.exports = getOrdinalNumber;

0 commit comments

Comments
 (0)