Advertisement
PurePureMilk

Stage 8 Level 17

Mar 13th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. var score = 0;
  2. // reset is called from mu
  3. function reset(){
  4. // reset images and score label on change
  5. onEvent("guess_dropdown", "click", function(event) {
  6. hideElement("frowny_img");
  7. hideElement("trophy_img");
  8. setText("score_label", "");
  9. });
  10. }
  11. // Add an if-else statement inside this event handler
  12. onEvent("roll_btn", "click", function() {
  13. reset();
  14. var dieValue = randomNumber(1, 6);
  15. setText("diceRoll_label", dieValue);
  16. if (getNumber("guess_dropdown") == getNumber("diceRoll_label")) {
  17. showElement("trophy_img");
  18. score = score+6;
  19. } else {
  20. showElement("frowny_img");
  21. score = score - 1;
  22. }
  23. setText("score_label", score);
  24. // if the guess is equal to dieValue
  25. // else
  26. //update the score label to the new score.
  27. });
  28. // You do not need to modify code below
  29. onEvent("guess_dropdown", "change", function() {
  30. reset();
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement