-
-
Notifications
You must be signed in to change notification settings - Fork 197
Glasgow | May-2025 | Adiyah Farhan | Sprint-3 #573
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 11 commits
35aa2c9
859b4f5
6045882
b93ece9
b35f735
5dac570
65c49be
fd402ee
9a056c0
d9099ed
36327a5
52d52a2
f661031
0fa7c90
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. Does this work when the card value is 10? |
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 === 90) return "Right angle"; | ||
else if (angle > 0 && angle < 90) return "Acute angle"; | ||
else if (angle > 90 && angle < 180) return "Obtuse angle"; | ||
else if (angle === 180) return "Straight angle"; | ||
else if (angle > 180 && angle < 360) return "Reflex 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
// add your completed function from key-implement here | ||
if (Math.abs(numerator) < denominator) return true; | ||
else if (Math.abs(numerator) > denominator) return false; | ||
else return false; | ||
} | ||
|
||
module.exports = isProperFraction; | ||
module.exports = isProperFraction; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
// replace with your code from key-implement | ||
let rank = card[0]; | ||
if (rank === "A") return 11; | ||
else if (rank >= "2" && rank <= "9") return Number(rank); | ||
else if (rank == "10" || rank == "J" || rank == "Q" || rank == "K") return 10; | ||
else return "Invalid Card rank"; | ||
} | ||
module.exports = getCardValue; | ||
module.exports = getCardValue; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
test("should return the numeric value corresponding to the rank", () => { | ||
expect(getCardValue("2♣︎")).toEqual(2); | ||
}); | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
test("should return the value 10, as these cards are worth 10 points each in blackjack", () => { | ||
expect(getCardValue("J♠︎")).toEqual(10); | ||
}); | ||
// Case 4: Handle Ace (A): | ||
test("should return 11 for Ace", () => { | ||
expect(getCardValue("A♦︎")).toEqual(11); | ||
}); | ||
// Case 5: Handle Invalid Cards: | ||
test("should return Invalid card rank", () => { | ||
expect(getCardValue("11")).toEqual("Invalid Card rank"); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
// Find the number of times findCharacter appears in stringOfCharacters | ||
|
||
let count = 0; | ||
for (let i = 0; i < stringOfCharacters.length; i++) { | ||
if (stringOfCharacters[i] === findCharacter) { | ||
// Increment the count | ||
count++; | ||
} | ||
} | ||
// Return the count | ||
return count; | ||
} | ||
|
||
module.exports = countChar; | ||
module.exports = countChar; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
let ordinal = ""; | ||
switch (true) { | ||
case num == 1 || (num % 10 == 1 && num != 11): | ||
ordinal = `${num}st`; | ||
break; | ||
case num == 11: | ||
ordinal = `${num}th`; | ||
break; | ||
case num == 2 || num == 22: | ||
ordinal = `${num}nd`; | ||
break; | ||
case num == 3 || (num % 10 == 3 && num != 13): | ||
ordinal = `${num}rd`; | ||
break; | ||
default: | ||
ordinal = `${num}th`; | ||
break; | ||
} | ||
return ordinal; | ||
} | ||
|
||
module.exports = getOrdinalNumber; | ||
module.exports = getOrdinalNumber; |
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. As a matter of practice, you might consider implementing repeat() yourself, rather than using the built-in string |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(str, count) { | ||
if (count < 0) { | ||
throw new Error("Invalid count"); | ||
} | ||
return str.repeat(count); | ||
} | ||
|
||
module.exports = repeat; | ||
module.exports = repeat; |
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 see any way you could remove the extra else branch here?