generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 116
ITPJAN|SARAAMIRI|Module-structuring-and-testing-data|sprint3|week3 #359
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
saraamiiri
wants to merge
11
commits into
CodeYourFuture:main
Choose a base branch
from
saraamiiri: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
11 commits
Select commit
Hold shift + click to select a range
1fb3c29
complete /key implement /get angle type
saraamiiri c15bd38
complete /1-key -implement proper fraction
saraamiiri 2809b18
complete key implement /card -value
saraamiiri 4b214b1
complete get card value
saraamiiri 01088f8
complete get angle type
saraamiiri 4f77dcd
complete proper fraction test
saraamiiri 97676b2
complete mandatory-rewrite/test .js
saraamiiri 5e1bd98
complete test file
saraamiiri 14d351f
complete count.test.js
saraamiiri f8fd1cd
complete get ordinal number .test.js
saraamiiri 381e662
complete repeat.test .js
saraamiiri 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 | ||
} | ||
|
||
module.exports = isProperFraction; | ||
// Handle case where the denominator is zero | ||
if (denominator === 0) { | ||
throw new Error('Denominator cannot be zero'); | ||
} | ||
|
||
// A proper fraction is one where the absolute value of the numerator is less than the denominator | ||
if (Math.abs(numerator) < Math.abs(denominator)) { | ||
return true; | ||
} | ||
|
||
// Otherwise, it's an improper fraction | ||
return false; | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
const isProperFraction = require("./2-is-proper-fraction"); | ||
|
||
test("should return true for a proper fraction", () => { | ||
expect(isProperFraction(2, 3)).toEqual(true); | ||
test("Identifies Proper Fraction", () => { | ||
expect(isProperFraction(2, 3)).toBe(true); | ||
}); | ||
|
||
// Case 2: Identify Improper Fractions: | ||
test("Identifies Improper Fraction", () => { | ||
expect(isProperFraction(5, 2)).toBe(false); | ||
}); | ||
|
||
// Case 3: Identify Negative Fractions: | ||
test("Identifies Negative Proper Fraction", () => { | ||
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. should also have a test for negative improper fraction. |
||
expect(isProperFraction(-4, 7)).toBe(true); | ||
}); | ||
|
||
// Case 4: Identify Equal Numerator and Denominator: | ||
test("Identifies Equal Numerator and Denominator as Improper", () => { | ||
expect(isProperFraction(3, 3)).toBe(false); | ||
}); |
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 getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
} | ||
|
||
const rank = card.slice(0, -1); // Extract the rank (everything except the suit emoji) | ||
|
||
if (rank === "A") return 11; | ||
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10; | ||
if (parseInt(rank) >= 2 && parseInt(rank) <= 9) return parseInt(rank); | ||
|
||
throw new Error("Invalid card rank"); | ||
} | ||
|
||
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
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,16 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
} | ||
|
||
let count = 0; | ||
// Loop through the string and count occurrences of `findCharacter` | ||
for (let i = 0; i < stringOfCharacters.length; i++) { | ||
if (stringOfCharacters[i] === findCharacter) { | ||
count++; | ||
} | ||
} | ||
return count; | ||
} | ||
|
||
|
||
|
||
|
||
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
24 changes: 22 additions & 2 deletions
24
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,25 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
function getOrdinalNumber(num) { // Convert the number to a string to easily access its last digits | ||
const lastDigit = num % 10; | ||
const lastTwoDigits = num % 100; | ||
|
||
// Handle special cases for numbers 11-13 | ||
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) { | ||
return `${num}th`; | ||
} | ||
|
||
// Handle normal cases for 1st, 2nd, 3rd, etc. | ||
switch (lastDigit) { | ||
case 1: | ||
return `${num}st`; | ||
case 2: | ||
return `${num}nd`; | ||
case 3: | ||
return `${num}rd`; | ||
default: | ||
return `${num}th`; | ||
} | ||
|
||
|
||
} | ||
|
||
module.exports = getOrdinalNumber; |
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.
if GetCardValue() didn't throw an exception, and returned a value like 10 for example, wouldn't the test still pass?