generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 197
London | May 2025 | Houssam Lahlah | Acoursework/sprint 3 #678
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
HoussamLh
wants to merge
25
commits into
CodeYourFuture:main
Choose a base branch
from
HoussamLh:acoursework/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
25 commits
Select commit
Hold shift + click to select a range
2dd0a78
explain Increment count variable by 1 after initialization.
HoussamLh 1bc5c74
Create initials variable by extracting first characters of first, mid…
HoussamLh b16d048
create two variable and Extract directory and file extension parts fr…
HoussamLh 625c114
Add comments explaining how num is calculated as a random integer bet…
HoussamLh f5522e7
Add explanation for incrementing count variable by 1 after initializa…
HoussamLh 2f17199
Update 0.js
HoussamLh 5e31d7c
Update 1.js
HoussamLh 5cf1cfd
Update 2.js
HoussamLh 2d1e8dd
Update 3.js
HoussamLh 4723bb9
implement getAngleType function with all angle cases and tests
HoussamLh 85a7125
implement isProperFraction with tests for positive, negative, equal n…
HoussamLh a6dd884
Implement getCardValue to return correct blackjack values for all val…
HoussamLh cb53f9a
Export complete getAngleType() function for Jest testing
HoussamLh 5a07227
Add Jest tests for all angle types in getAngleType()
HoussamLh a417fa0
Implement isProperFraction to handle proper, improper, and negative f…
HoussamLh 461d0b6
Add unit tests for isProperFraction covering all key scenarios
HoussamLh 057740b
Implement getCardValue function with support for number, face, and ac…
HoussamLh 48444ef
Add tests for getCardValue covering number cards, face cards, and inv…
HoussamLh 633a7af
Revert Sprint-1 folder to CYF's original version
HoussamLh 6d8d7bb
Implement countChar function to count occurrences of a character in a…
HoussamLh 50eaeb4
Implement getOrdinalNumber to handle ordinal suffixes correctly
HoussamLh e2c7e37
Implement repeat function with parameters and error handling
HoussamLh 276c348
Implement find function to locate character index in string with deta…
HoussamLh 28dfefd
just to writing a missing bits.
HoussamLh c3ed0d1
Implement credit card validator function
HoussamLh 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
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,15 @@ | ||
// Explanation: | ||
// It checks if the absolute value of the numerator | ||
// is less than the absolute value of the denominator. | ||
|
||
|
||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
if (denominator === 0) { | ||
throw new Error("Denominator cannot be zero"); | ||
} | ||
|
||
return Math.abs(numerator) < Math.abs(denominator); | ||
} | ||
|
||
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,15 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
const rank = card.slice(0, -1); // All characters except the last one (suit) | ||
|
||
if (!rank) throw new Error("Invalid card rank"); | ||
|
||
if (rank === "A") return 11; | ||
if (["K", "Q", "J", "10"].includes(rank)) return 10; | ||
|
||
const number = Number(rank); | ||
if (number >= 2 && number <= 9) return number; | ||
|
||
throw new Error("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,33 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
// Case 4: Handle Ace (A): | ||
// Case 5: Handle Invalid Cards: | ||
expect(getCardValue("A♠")).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10) | ||
test("should return 5 for Five of Hearts", () => { | ||
expect(getCardValue("5♥")).toEqual(5); | ||
}); | ||
|
||
test("should return 10 for Ten of Diamonds", () => { | ||
expect(getCardValue("10♦")).toEqual(10); | ||
}); | ||
|
||
// Case 3: Handle Face Cards (J, Q, K) | ||
test("should return 10 for Jack of Clubs", () => { | ||
expect(getCardValue("J♣")).toEqual(10); | ||
}); | ||
|
||
test("should return 10 for Queen of Spades", () => { | ||
expect(getCardValue("Q♠")).toEqual(10); | ||
}); | ||
|
||
test("should return 10 for King of Hearts", () => { | ||
expect(getCardValue("K♥")).toEqual(10); | ||
}); | ||
|
||
// Case 5: Handle Invalid Cards | ||
test("should throw an error for invalid card rank", () => { | ||
expect(() => getCardValue("Z♣")).toThrow("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,11 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
let count = 0; | ||
for (let char of stringOfCharacters) { | ||
if (char === findCharacter) { | ||
count++; | ||
} | ||
} | ||
return count; | ||
} | ||
|
||
module.exports = countChar; |
11 changes: 9 additions & 2 deletions
11
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,12 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
const suffixes = ["th", "st", "nd", "rd"]; | ||
const value = num % 100; | ||
if (value >= 11 && value <= 13) { | ||
return num + "th"; | ||
} | ||
const lastDigit = num % 10; | ||
const suffix = suffixes[lastDigit] || "th"; | ||
return num + suffix; | ||
} | ||
|
||
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
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,8 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(str, count) { | ||
if (count < 0) { | ||
throw new Error("Count must be non-negative"); | ||
} | ||
return str.repeat(count); | ||
} | ||
|
||
module.exports = repeat; | ||
module.exports = repeat; |
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.
I can see from your later implementation in section 2 you got this right. If you made changes, remember to copy them over