Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thetripler
Copy link

No description provided.

Copy link

@aghaffar570 aghaffar570 left a 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/>"

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

Comment on lines +72 to +85
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
}

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 ) {

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) {

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();

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants