generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
London 11 | Pezhman-Azizi | Structuring-and-testing-data | week3 | sprint 3 #214
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
Pezhman-Azizi
wants to merge
19
commits into
CodeYourFuture:main
Choose a base branch
from
Pezhman-Azizi:sprint3
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
19 commits
Select commit
Hold shift + click to select a range
782bd64
implement/get-angel-type
Pezhman-Azizi eda8a0d
implement/get card value
Pezhman-Azizi ba2e832
implement/proper-fraction
Pezhman-Azizi 2f76a64
implement/is validTriangle
Pezhman-Azizi 9f854dc
implement/rotate character
Pezhman-Azizi 6023fb8
revise/implement/count.js with test file
Pezhman-Azizi 2714bd0
revise/getOrdinalNumber.js along with test
Pezhman-Azizi 61e406a
revise/implement/prime.js along with test
Pezhman-Azizi e46ba79
revise/implement/password-validation
Pezhman-Azizi ad3bbe8
revise/implement/find.js
Pezhman-Azizi 73cbf25
investigate/find.js
Pezhman-Azizi 50b40f1
Added more test cases.
Pezhman-Azizi 8496e7a
Enhance getCardValue function with validation and edge case handling
Pezhman-Azizi 91f4f05
Add support for negative values in isProperFraction function
Pezhman-Azizi c131550
Simplify isValidTriangle function by removing redundant positivity check
Pezhman-Azizi a9391df
Refactor rotateCharacter function to handle non-letter characters and…
Pezhman-Azizi ac1e2a1
Improved getOrdinalNumber function by using const for immutables
Pezhman-Azizi 859dbdb
Optimize isPrime function for better performance
Pezhman-Azizi 77aa3d7
changed the place of console.log
Pezhman-Azizi 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// function countChar(str, char){ | ||
// let count = 0; | ||
// str.split("").forEach(element => { | ||
// if (element === char){ | ||
// count+=1;} | ||
// }); | ||
// if (count > 0){ | ||
// return `${char} appears ${count} times in ${str}`; | ||
// }else{ | ||
// return `no occurrences of the "${char}" were found in the "${str}"`; | ||
// } | ||
// } | ||
// // exports.countChar = {countChar}; | ||
// module.exports = { countChar }; | ||
function countChar(str, char) { | ||
let count = 0; | ||
str.split("").forEach(element => { | ||
if (element === char) { | ||
count += 1; | ||
} | ||
}); | ||
|
||
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. Maybe the spec wasn't clear enough. Usually a function that "count something" would simply return an integer. |
||
if (count > 0) { | ||
return `${char} appears ${count} times in ${str}`; | ||
} else { | ||
return `no occurrences of the "${char}" were found in the "${str}"`; | ||
} | ||
} | ||
|
||
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function getOrdinalNumber(number) { | ||
const firstDigit = number % 10; // First digit of the number | ||
const secondDigit = number % 100; // Last two digits of the number | ||
|
||
let suffix = "th"; // Default suffix | ||
|
||
// Handle special cases for 11th, 12th, and 13th | ||
if (secondDigit >= 11 && secondDigit <= 13) { | ||
return `${number}${suffix}`; | ||
} else if (firstDigit === 1) { | ||
suffix = "st"; | ||
} else if (firstDigit === 2) { | ||
suffix = "nd"; | ||
} else if (firstDigit === 3) { | ||
suffix = "rd"; | ||
} | ||
return `${number}${suffix}`; | ||
} | ||
|
||
console.log(getOrdinalNumber(45)); // "45th" | ||
console.log(getOrdinalNumber(1)); // "1st" | ||
console.log(getOrdinalNumber(2)); // "2nd" | ||
console.log(getOrdinalNumber(3)); // "3rd" | ||
console.log(getOrdinalNumber(11)); // "11th" | ||
console.log(getOrdinalNumber(112)); // "112th" | ||
|
||
module.exports = getOrdinalNumber; // Export the function |
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.
Could also test negative values in numerator and/or denominator (for cases when |numerator| < |denominator|).
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.
expanded the test cases to include scenarios where either the numerator, the denominator, or both are negative, ensuring that the function handles these properly.