generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Open
AdiyahFarhan
wants to merge
14
commits into
CodeYourFuture:main
Choose a base branch
from
AdiyahFarhan:coursework/sprint-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35aa2c9
Exercise 1-key-implement done
AdiyahFarhan 859b4f5
code from ./1-key-implement/1-get-angle-type copied in file ./2-manda…
AdiyahFarhan 6045882
Test has been written in file ./2-mandatory-rewrite/1-get-angle-type.…
AdiyahFarhan b93ece9
Added completed function from ./1-key-implement/2-is-proper-fraction.js
AdiyahFarhan b35f735
Write Test for different cases in 2-is-proper-fraction.test.js by usi…
AdiyahFarhan 5dac570
Added code from ./1-key implement/3-get-card-value.js
AdiyahFarhan 65c49be
Write test for the possible cases in 3-get-card-c-value.test.js
AdiyahFarhan fd402ee
Implements the function countChar() to find the requested char in the…
AdiyahFarhan 9a056c0
Implement the function getOrdinalNumber() to convert the number into …
AdiyahFarhan d9099ed
The function repeat() has been implemented and tested for all the pos…
AdiyahFarhan 36327a5
Function passwordValidator has been implemented to check for the vali…
AdiyahFarhan 52d52a2
file updated by eliminating extra else statement
AdiyahFarhan f661031
File updated so that it can works for value '10'
AdiyahFarhan 0fa7c90
Implementing the function using the loop instead of using the built-i…
AdiyahFarhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?