-
-
Notifications
You must be signed in to change notification settings - Fork 337
London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 3 | practice tdd #1265
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
djebsoft
wants to merge
17
commits into
CodeYourFuture:main
Choose a base branch
from
djebsoft:sprint-3/practice-TDD
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 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b34e66c
test count function
djebsoft efc78a8
testing
djebsoft 293e98e
test the function countchar
djebsoft edb4fe4
testing
djebsoft fc349ab
implement count function
djebsoft eb8edda
test getOrdinalNumber function
djebsoft 4b70646
implement the function getOrdinalNumber
djebsoft 3c69efb
test the repeatStr function
djebsoft 7661229
implement repeatStr function
djebsoft 1c57e2b
fixed the loop
djebsoft 0e0c2f5
created variables to store the values of repeatedly used expressions
djebsoft ca4e87b
made some changes to make the test more informative
djebsoft 75c15af
simplyfying the code by using the repeat methodand making
djebsoft 02245db
renamed variables
djebsoft 73e0c61
fixed the comparison between a sting and a number to between two strings
djebsoft 28288c3
replacement jest output with the detailed conditions
djebsoft 7561430
using .slice() instead of index to extract the last character
djebsoft 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
| 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 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
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 getOrdinalNumber(num) { | ||
| return "1st"; | ||
| let lastDigit = num % 10; | ||
| let lastTwoDigits = num % 100; | ||
| if (lastDigit === 1 && lastTwoDigits !== 11) { | ||
| // we also can use if (num[-1]==="1" && num.slice(-2)!=="11") | ||
| return num + "st"; | ||
| } else if (lastDigit === 2 && lastTwoDigits !== 12) { | ||
| // we also can use if (num[-1]==="2" && num.slice(-2)!=="12") | ||
| return num + "nd"; | ||
| } else if (lastDigit === 3 && lastTwoDigits !== 13) { | ||
| // we also can use if (num[-1]==="3" && num.slice(-2)!=="13") | ||
| return num + "rd"; | ||
| } else { | ||
| return num + "th"; | ||
| } | ||
| } | ||
|
|
||
| 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,17 @@ | ||
| function repeatStr() { | ||
| return "hellohellohello"; | ||
| function repeatStr(str, count) { | ||
| if (count >= 0) { | ||
| return str.repeat(count); | ||
| } else { | ||
| throw new Error("Count cannot be a negative number"); | ||
| } | ||
| } | ||
| // I can make the 3 valid cases in 1 case with the repeat method as folows: | ||
| // function repeatStr(str, count) { | ||
| // if (count >= 0) { | ||
| // return str.repeat(count); | ||
| // } else { | ||
| // throw new Error("Count cannot be a negative number"); | ||
| // } | ||
| // } | ||
|
|
||
| module.exports = repeatStr; |
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.
Note:
num[-1]is not the syntax to extract the last character in JavaScript. It will be evaluated toundefined.Use
.at(-1)or.slice(-1)instead.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 changed it to .slice() instead of index to extract the last character
thank you