generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 301
ITP-Jan 2025 | London | Maryna Romanova | Module-Structuring-and-Testing-Data | Week 6 | Sprint 3 #340
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
MarynaRomashca
wants to merge
6
commits into
CodeYourFuture:main
from
MarynaRomashca:coursework/sprint-3+
Closed
ITP-Jan 2025 | London | Maryna Romanova | Module-Structuring-and-Testing-Data | Week 6 | Sprint 3 #340
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
291da1e
Sprint-1.start
MarynaRomashca c0f3ab7
sprint-3
MarynaRomashca b3e431c
Sprint-3+ 3.1
MarynaRomashca 1275374
Sprint3+ fix 1
MarynaRomashca 25fe73b
Sprint-3 updated 3.2.
MarynaRomashca eb90b74
Sprint 3+ finish 3.3
MarynaRomashca 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
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
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 | ||
| } | ||
| if (denominator === 0) return false; | ||
| return Math.abs(numerator) < Math.abs(denominator); | ||
| } | ||
| // function isProperFraction(numerator, denominator) { | ||
| // if (numerator < denominator) return true; | ||
| // else return false; | ||
| // // add your completed function from key-implement here | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| 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,13 @@ | ||
| function getCardValue(card) { | ||
|
|
||
| // replace with your code from key-implement | ||
| return 11; | ||
| } | ||
|
|
||
| function getCardValue(card) { | ||
| const rank = card.slice(0, -1); | ||
| if (rank === "A") return 11; | ||
| if (["J", "Q", "K", "10"].includes(rank)) return 10; | ||
| if (/^[2-9]$/.test(rank)) return Number(rank); | ||
| throw new Error("Invalid") | ||
| } | ||
|
|
||
|
|
||
| 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,37 @@ | ||
| 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("Handle Number Cards 2-10", () => { | ||
| const fiveOfHearts = getCardValue("5♥"); | ||
| expect(fiveOfHearts).toEqual(5); | ||
| }); | ||
|
|
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("Handle Face Cards J, Q, K", () => { | ||
| const handleFace = getCardValue("Q♥"); | ||
| expect(handleFace).toEqual(10); | ||
| }); | ||
|
|
||
| // Case 4: Handle Ace (A): | ||
| // Case 5: Handle Invalid Cards: | ||
| test("Handle Ace (A)", () => { | ||
| const handleAce = getCardValue("A♥"); | ||
| expect(handleAce).toEqual(11); | ||
| }); | ||
|
|
||
| // // Case 5: Handle Invalid Cards: | ||
| // test("Handle Ace (A)", () => { | ||
| // const handleAce = getCardValue("29♠"); | ||
| // expect(handleAce).toEqual("Invalid"); | ||
| // }); | ||
|
|
||
| //Case 5: Handle Invalid Cards: | ||
| test("Handle Invalid Cards", () => { | ||
| expect(() => getCardValue("Z♥")).toThrow("Invalid"); | ||
| expect(() => getCardValue("29♠")).toThrow("Invalid"); | ||
| expect(() => getCardValue("2.1♠")).toThrow("Invalid"); | ||
| }); |
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.charAt(i) === findCharacter ) { | ||
| count++ | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| console.log (countChar('Maryna' , '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
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(number) { | ||
|
|
||
| if (number < 1) return number; | ||
|
|
||
| let suffix = "th"; | ||
| if (number % 100 !== 11 && number % 100 !== 12 && number % 100 !== 13) { | ||
| if (number % 10 === 1) suffix = "st"; | ||
| else if (number % 10 === 2) suffix = "nd"; | ||
| else if (number % 10 === 3) suffix = "rd"; | ||
| } | ||
|
|
||
|
|
||
| return number + suffix; | ||
| } | ||
|
|
||
| console.log(getOrdinalNumber(1)); // "1st" | ||
| console.log(getOrdinalNumber(2)); // "2nd" | ||
| console.log(getOrdinalNumber(3)); // "3rd" | ||
| console.log(getOrdinalNumber(4)); // "4th" | ||
| console.log(getOrdinalNumber(11)); // "11th" | ||
| console.log(getOrdinalNumber(22)); // "22nd" | ||
| console.log(getOrdinalNumber(103)); // "103rd" | ||
|
|
||
|
|
||
| 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(word, count) { | ||
| if (count < 0) { | ||
| throw new Error("Count cannot be negative"); | ||
| } | ||
| return word.repeat(count); | ||
| } | ||
|
|
||
| console.log (repeat ("hello")) | ||
|
|
||
| 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.
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.
Does your function return the value you expected from each of the following function calls?
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.
No, the function does not return this numeric. In all three cases, the function throws an "Invalid card rank" error.