generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 302
London | May-2025 | Ikenna Agulobi | Structuring and Testing Data sprint-3 #614
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
Closed
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
29f288e
Implemented condition to check if angle is less than 90
ike-agu bb789a2
added conditional statements and assertions to complete exercise 1-ge…
ike-agu de201cb
added test assertions to complete exercise 2-is-proper-fraction
ike-agu dbe53d3
Impleneted function to get card value for exercise 3-get-card-value.js
ike-agu 9756c95
added completed getAngleType funtion from Key-implement exercise
ike-agu e1f86d2
Added tests for get angle type exercise
ike-agu 2f478fd
added my isProperFraction function from key-implement
ike-agu f796929
I added tests is Proipoer Fraction exercise
ike-agu 3fe535b
added codes from getCardValue function
ike-agu 5b28aa1
added tests for get card value exercise
ike-agu a124d85
added completed getAngleType funtion from Key-implement exercise
ike-agu 65fb383
added tests for getOrdinalNumber from 1 - 11
ike-agu a777952
added tests cases for repeat.test exercise
ike-agu 0071b2f
Implemented credit card validator function
ike-agu 1e9d34d
Added comments to answer questions regarding the function find and th…
ike-agu 8d57ee1
implemented passwordValidator function
ike-agu 2c3d18a
added test to check if password has uppercase or lowercase letter
ike-agu 4dc0a9e
added test to check if password has atleast one number 0-9
ike-agu 7cd8988
added test to check if password has atleast one non-aphanumeric symbols
ike-agu 1f98cca
fixed test to check if password has already been used. Changed return…
ike-agu 60897ed
Changed return message for password already been used to equals to f…
ike-agu 9e62f36
Implemented get get ordinal number function
ike-agu 9de4207
fixed test cases for get ordinal numbers function
ike-agu 224044d
fixed test case password has atleast 5 characters
ike-agu 1e0ea6c
Implemented count Character function
ike-agu 79fcbe9
Implemented repeat function
ike-agu 826f604
Implemented functionality to check the cards are not all the same digit
ike-agu 24e0cbe
edit the file in line 4
ike-agu bee5248
added checks for angle less than or equals to zero and the ones great…
ike-agu 8947ab5
implemented isProper fraction to ensure denominator is not zero. I al…
ike-agu 155ed1e
updated get-card-value.js to ensure only standard card ranks are acce…
ike-agu c619fd9
updated get-card-value.js to throw new Error(Invalid Card rank).
ike-agu 03edb9b
implemented is proper fraction to handle negative values and zero den…
ike-agu 30550bc
fixed function to handle zero denominators and negative numbers
ike-agu 2b0b26f
grouped test cases under the category append 'th' to numbers ending …
ike-agu 4180eb3
updated get-card-value.js to throw new Error(Invalid Card rank).
ike-agu 32ab610
I group test cases for numbers ending in 1,2 and 3 to improve coverag…
ike-agu 586fbd2
Implemented throw new error message
ike-agu 6cd07d3
fixed the test case to throw error when count is negative
ike-agu ffd50fa
I added test cases to to return false when the password is invalid e.…
ike-agu 9eff376
I added = sign to check if sum is <= to 16
ike-agu dab298c
added lowercase t
ike-agu ec0084a
fixed function to throw new error when denominator is zero
ike-agu 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,17 @@ | ||
| 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") | ||
| } | ||
| if( Math.abs(numerator) < Math.abs(denominator)){ | ||
| return true; | ||
| }else{ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| module.exports = isProperFraction; | ||
| console.log(isProperFraction(-3, 0)); | ||
|
|
||
| // console.log(isProperFraction(-4, 6)); | ||
| 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,18 @@ | ||
| function getCardValue(card) { | ||
| // replace with your code from key-implement | ||
| return 11; | ||
| let rank = card.slice(0, -1); // this line removes the emojis | ||
|
|
||
| const rangeTwoToTenArray = ["2", "3", "4", "5", "6", "7", "8", "9", "10"];// | ||
|
|
||
| if (rank === "A") { | ||
| return 11; | ||
| } else if (rangeTwoToTenArray.includes(rank)) { | ||
| return parseInt(rank); | ||
| } else if (rank === "J" || rank === "Q" || rank === "K") { | ||
| return 10; | ||
| } else { | ||
| 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,23 @@ | ||
| const getCardValue = require("./3-get-card-value"); | ||
|
|
||
| test("should return 11 for Ace of Spades", () => { | ||
| const aceofSpades = getCardValue("A♠"); | ||
| expect(aceofSpades).toEqual(11); | ||
| expect(getCardValue("A♠")).toEqual(11); | ||
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("Should return rank number between 2 and 10",()=>{ | ||
| expect(getCardValue("5♥")).toEqual(5); | ||
| }); | ||
|
|
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("Should return 10 for Face Cards J, Q, K", () => { | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| expect(getCardValue("J♣")).toEqual(10); | ||
| expect(getCardValue("Q♦")).toEqual(10); | ||
| }); | ||
|
|
||
| // Case 4: Handle Ace (A): | ||
| // Case 5: Handle Invalid Cards: | ||
| test("should throw an error indicating Invalid card rank.", () => { | ||
| expect(() => getCardValue("")).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,12 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| function countChar(strOfCahracters, findcharacter) { | ||
| let count = 0; | ||
| for (let i = 0; i < strOfCahracters.length; i++) { | ||
| if (strOfCahracters[i] === findcharacter) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| module.exports = countChar; | ||
| // console.log(countChar("aaaaa", "a")); | ||
| 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
21 changes: 19 additions & 2 deletions
21
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,22 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| let lastNumber = num % 10; // Using the modulo operator to get the last digit of the number. | ||
| let lastTwoNumbers = num % 100; //Using the modulo operator to get the last two digits of the number. | ||
|
|
||
| if (lastTwoNumbers === 11 || lastTwoNumbers === 12 || lastTwoNumbers === 13) { | ||
| return num + "th"; | ||
| } | ||
|
|
||
| if (lastNumber === 1) { | ||
| return num + "st"; | ||
| } else if (lastNumber === 2) { | ||
| return num + "nd"; | ||
| } else if (lastNumber === 3) { | ||
| return num + "rd"; | ||
| } else { | ||
| return num + "th"; | ||
| } | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
| console.log(getOrdinalNumber(3)); | ||
|
|
||
| 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,10 @@ | ||
| function repeat() { | ||
| return "hellohellohello"; | ||
| function repeat(str, count) { | ||
| if (count < 0) { | ||
| throw new Error("Negative numbers are not valid!"); | ||
| } else { | ||
| return str.repeat(count); | ||
| } | ||
| } | ||
|
|
||
| module.exports = repeat; | ||
| // console.log(repeat("", -1)); | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.