-
Notifications
You must be signed in to change notification settings - Fork 10
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
Homework 04 - homework with bonuses completed #2
base: master
Are you sure you want to change the base?
Conversation
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.
@thetripler Great Work on the rock-scissor-paper game. for larger codebases/exercises, it helps to group similar things by functionality and purpose. it comes in handy with debugging and collaboration.
💯 on the additional features.
|
||
// console.log(`Player chose ${playerChoice}, Bot chose ${botChoice} `) | ||
|
||
output += "<p>You played <u>"+playerChoice+"</u>,The bot played <u>"+botChoice+"</u>.<p/>" |
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.
@thetripler for each round, a new output
would be appended to the existing output. Not sure if this was intended, but to have it reset, you'll want to change the assignment: output = content
output += "<p>You Win :)</p>" | ||
playerScore = playerScore + 1 | ||
|
||
// Bonus Requirement 3 | ||
playerBonus = playerBonus + 1 | ||
botBonus = 0 | ||
|
||
if (playerBonus >= 3) { | ||
|
||
playerScore = playerScore + 2 | ||
$('#bonus').html("<p>You got two bonus points for winning 3 hands in a row</p>") | ||
botBonus = 0 | ||
playerBonus = 0 | ||
} |
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.
@thetripler can be compressed into a function and the values that change can be passed down into the function depending on the logic.
check here for an alternative approach
|
||
|
||
// Bonus Requirement 1 | ||
if (playerScore >= 10 || botScore >= 10 ) { |
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.
@thetripler Great Job incorporating additional features!! 🥇
$('#reloadgame').hide() | ||
|
||
|
||
$(".choice-buttons").on("click", function (e) { |
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.
@thetripler currently this callback function is handling everything inside, which makes sense. consider breaking the code up into functional parts for brevity and to avoid repeating similar logic.
Great use of comments. helps with identifying the step by step procedures 👍
}) | ||
|
||
$("#reset").on("click", function (e) { | ||
event.preventDefault(); |
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.
@thetripler the event
object is passed via the callback function, which in this case is e
.
A great use case for handling bubbling
No description provided.