-
-
Notifications
You must be signed in to change notification settings - Fork 301
LON | ITP JAN-25 | Amir Montazeri | Module Structuring And Data | Sprint3 tasks | Week 3 #314
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
LON | ITP JAN-25 | Amir Montazeri | Module Structuring And Data | Sprint3 tasks | Week 3 #314
Conversation
cjyuan
left a comment
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.
Look great!
getCardValue(card) could be improved to deal with more invalid cases.
Feel free to mark this as completed when you have made the necessary change.
| if (angle === 90) return "Right angle"; | ||
| if (angle < 90) return "Acute angle"; | ||
| if (angle > 90 && angle < 180) return "Obtuse angle"; | ||
| if (angle === 180) return "Straight angle"; | ||
| if (angle > 180 && angle < 360) return "Reflex angle"; | ||
| } |
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.
The spec does not specify what to do when angle >= 360. How would you handle such a case if it were up to you?
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.
@cjyuan Thanks for your review! I've updated the function to handle additional cases.
| const rank = card.slice(0, -1); | ||
| if (rank === "A") return 11; | ||
| if (["K", "Q", "J", "10"].includes(rank)) return 10; | ||
| if (!isNaN(rank) && rank >= 2 && rank <= 9) return Number(rank); |
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?
getCardValue("010♠");
getCardValue("02♠");
getCardValue("0x02♠");
getCardValue("2.1♠")
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 updated the function so now It shows that the function throwing errors for invalid card inputs .
| @@ -1,5 +1,5 @@ | |||
| function countChar(stringOfCharacters, findCharacter) { | |||
| return 5 | |||
| return stringOfCharacters.split(findCharacter).length - 1; | |||
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.
Very interesting and elegant approach!
Since a character is of type "string" in JS, how would you modify your approach to deal with cases when findCharacter is "abc" or ""?
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.
The current approach works for single characters but can also handle multi-character substrings, However, there are some edge cases, so improved the function to handle theme.
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.