generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 196
ITP JAN-25-London | MIKIYAS GEBREMICHAEL | STRUCTURING AND TESTING DATA | SPRINT-3 | WEEK - 3 #285
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
15 commits
Select commit
Hold shift + click to select a range
3049ed3
This commit if for sprint 3 folder 1 question 1.
Mikiyas-STP 801b4c7
This Answer if for Sprint 3 Folder 1 question 2
Mikiyas-STP 1be3543
This is the answer for sprint 3 folder 1 question 3.
Mikiyas-STP 747886f
This commit is done for question 1 of Sprint3 section 2
Mikiyas-STP b23f54f
This commit is done for question 2 of Sprint3 folder 2
Mikiyas-STP b5bac55
This commit is done for question 3 of Sprint3 folder 2
Mikiyas-STP 4f93461
This commit is done for the first work(counting character) of sprint …
Mikiyas-STP 3fe3a29
This is for the third folder of sprint 3 get ordinary number. :This c…
Mikiyas-STP 4916032
this commit is made for the final question of section 3 : repeated s…
Mikiyas-STP 3ca0f83
answer for section 4 stretch investigate | Credit Card Validator
Mikiyas-STP 144ec9c
this commit is done for sprint3 stretch-investigate| find.js
Mikiyas-STP 1da8c37
this commit is made for the password validator stretch exercise in sp…
Mikiyas-STP 8c8ff8a
stretch to sprint 3 mandatory practice| repeat.js
Mikiyas-STP 41ee6f1
syntax error fix
Mikiyas-STP 2087ce9
alternate way for sprint 1 key-implement | 2-is-proper-fraction.js
Mikiyas-STP 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,13 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
else if (numerator > denominator) return false; // Improper Fraction check | ||
else if (numerator<0 && denominator>numerator) return true;// Negative Fraction check | ||
else if (numerator===denominator) return false;//equalFraction | ||
//down here are part of the Stretch goals | ||
else if (numerator === 0 ) return true; //Proper fraction | ||
else if (denominator === 0) return false; //Invalid input | ||
else if (numerator < 0 && denominator < 0 && numerator > denominator) return true; //Negative cancellation | ||
} | ||
|
||
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,8 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
let rank = card.slice(0, -1); | ||
if (rank === "A") return 11; | ||
else if (rank>="2" && rank<="9") return Number(rank); | ||
else if (rank==="10" || rank==="J" || rank==="Q" || rank==="K") return 10; | ||
else return "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
const aceOfSpades = getCardValue("A♠"); | ||
expect(aceOfSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
test("should return 5 for 5 of Spades", () => { | ||
const aceOfSpades = getCardValue("5♠"); | ||
expect(aceOfSpades).toEqual(5); | ||
}); | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
test("should return 10 for Q of Spades", () => { | ||
const aceOfSpades = getCardValue("Q♠"); | ||
expect(aceOfSpades).toEqual(10); | ||
}); | ||
// Case 4: Handle Ace (A): | ||
test("should return 11 for Ace of Spades", () => { | ||
const aceOfSpades = getCardValue("A♠"); | ||
expect(aceOfSpades).toEqual(11); | ||
}); | ||
// Case 5: Handle Invalid Cards: | ||
test("should return Invalid card rank for Invalid Inputs", () => { | ||
const aceOfSpades = getCardValue("M♠"); | ||
expect(aceOfSpades).toEqual("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,6 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
let splitArr = stringOfCharacters.split(findCharacter); | ||
return splitArr.length-1; | ||
} | ||
|
||
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
8 changes: 6 additions & 2 deletions
8
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,9 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
if(num ===1 ) return "1st"; | ||
else if(num === 2 ) return "2nd"; | ||
else if(num === 3 ) return "3rd"; | ||
else return num + "th"; | ||
|
||
} | ||
|
||
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,15 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(strToRepeat, howMuchRep) { | ||
if (!Number.isInteger(howMuchRep)) { | ||
return "Float values are invalid"; | ||
} | ||
if (howMuchRep < 0) { | ||
return "Negative Counts are not valid"; | ||
} | ||
return strToRepeat.repeat(howMuchRep); | ||
} | ||
|
||
module.exports = repeat; | ||
module.exports = repeat; | ||
|
||
|
||
|
||
module.exports = repeat; |
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.
what if we also use decimal values like 2.5 how can we write test for this case? consider this one as a challange
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.
function repeat(strToRepeat, howMuchRep) {
if (!Number.isInteger(howMuchRep)) {
return "Float values are invalid";
}
if (howMuchRep < 0) {
return "Negative Counts are not valid";
}
return strToRepeat.repeat(howMuchRep);
} i fixed the code for Non integer and negative values :
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.
please instead of writing as comment, add these changes in your new commit
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.
yes i did