-
-
Notifications
You must be signed in to change notification settings - Fork 193
Sheffield | May-2025 | Declan Williams | Sprint-3 #623
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
be25f2c
4fa86db
d317d4f
dea34f8
952fd14
8cf3f58
6da0615
45209eb
37f345d
ed4eaf3
a0d4fcf
d32c392
e7f3d74
2e2d63c
900385e
67c92c2
60ed74f
bcdba1c
a16c211
aced4d1
0a913b0
de7632b
aa7b3ee
d2a8646
9798ed9
63a66e2
c89c3b8
2b44bf7
df5287d
1f02ed6
900db99
5d2265b
525641a
4f81c7d
d34ba19
dd38ca5
5798163
a8d9ac3
1a34fcf
c5d4342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, -4/7 == 4/-7, and -4/-7 == 4/7. Similarly, -5/2 == 5/-2, and -5/-2 == 5/2. Hint: we can compare the absolute value of both parameters instead. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
else return false; // returns false if numerator is not less than denominator | ||
} | ||
|
||
module.exports = isProperFraction; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) | ||
if (rank === "A") return 11; // this checks for Aces | ||
// Handle Number Cards (2-9) | ||
if (rank === "2") return 2; // this checks for the twos | ||
if (rank === "3") return 3; // this checks for the threes | ||
if (rank === "4") return 4; // this checks for the fours | ||
if (rank === "5") return 5; // this should check for fives | ||
if (rank === "6") return 6; // this checks for the sixes | ||
if (rank === "7") return 7; // this checks for the sevens | ||
if (rank === "8") return 8; // this checks for the eights | ||
if (rank === "9") return 9; // this checks for the nines | ||
// Handle Face Cards (J, Q, K) And 10's | ||
if (rank === "J") return 10; // this checks for Jacks | ||
if (rank === "Q") return 10; // this checks for Queens | ||
if (rank === "K") return 10; // this checks for Kings | ||
if (rank === "10") return 10; // this checks for Tens | ||
// if none of the above its an invalid card and throw an error | ||
throw new Error("Invalid card rank."); // this will throw an error if the card is not a valid rank | ||
} | ||
|
||
module.exports = getCardValue; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
// start a count of 0 | ||
let count = 0; | ||
|
||
// check each of the characters in the string one by one. | ||
for (let i = 0; i < stringOfCharacters.length; i++) { | ||
// checks if the current characters matches the one were looking for in the string. | ||
if (stringOfCharacters[i] === findCharacter) | ||
// if it does, we increment the count by 1. | ||
count = count + 1; | ||
} | ||
|
||
return count; | ||
} | ||
console.log(countChar("aaaaa", "a")); // 5 | ||
console.log(countChar("hello", "l")); // 2 | ||
|
||
module.exports = countChar; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
const lastTwoDigits = num % 100; // gets the last two digits of the number because some like 11, 12, 13 are special cases. | ||
const lastDigit= num % 10; // gets the last digit to decide if its going to be "St, Nd, Rd" | ||
|
||
// handles special cases "11, 12 ,13" to always end in "Th". | ||
if(lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13){ | ||
return num + "th"; | ||
} | ||
|
||
// will return "St" if the number ends in 1. | ||
if (lastDigit === 1){ | ||
return num + "st"; | ||
} | ||
// will return "Nd" if the number ends in 2. | ||
if (lastDigit === 2){ | ||
return num + "nd"; | ||
} | ||
// will return "Rd" if the number ends in 3. | ||
if (lastDigit === 3){ | ||
return num + "rd"; | ||
} | ||
|
||
// will return all numbers that end in 4, 5, 6, 7, 8, 9 with "Th". | ||
return num + "th"; | ||
} | ||
|
||
module.exports = getOrdinalNumber; |
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.
Your function can return
undefined
for some values ofangle
. To ensure reliability, please update the function so it always returns a defined value (which can be "Invalid angle") or throws an error. Functions that are expected to return a result should never returnundefined
.Note: the spec fails to mention angles <= 0 are not "Acute angle".