Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var score = 0;
- // reset is called from mu
- function reset(){
- // reset images and score label on change
- onEvent("guess_dropdown", "click", function(event) {
- hideElement("frowny_img");
- hideElement("trophy_img");
- setText("score_label", "");
- });
- }
- // Add an if-else statement inside this event handler
- onEvent("roll_btn", "click", function() {
- reset();
- var dieValue = randomNumber(1, 6);
- setText("diceRoll_label", dieValue);
- if (getNumber("guess_dropdown") == getNumber("diceRoll_label")) {
- showElement("trophy_img");
- score = score+6;
- } else {
- showElement("frowny_img");
- score = score - 1;
- }
- setText("score_label", score);
- // if the guess is equal to dieValue
- // else
- //update the score label to the new score.
- });
- // You do not need to modify code below
- onEvent("guess_dropdown", "change", function() {
- reset();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement