Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. /*jslint browser: true, devel: true, eqeq: true, plusplus: true, sloppy: true, vars: true, white: true*/
  2. /*eslint-env browser*/
  3. /*eslint 'no-console': 0*/
  4.  
  5.  
  6. function pick() {
  7. var imgArray = ['kabutops.png', 'wobbuffet.png','articuno.png'];
  8. var rand = imgArray[Math.floor(Math.random() * imgArray.length)]; //Pak een random naam uit de lijst
  9. document.querySelectorAll('img')[0].src = 'images/' + rand;
  10. var remove = rand;
  11. var keuze1= remove.substr(0, remove.lastIndexOf('.'));
  12. console.log('Random pick ' + keuze1);
  13. return keuze1;
  14. }
  15. pick();
  16.  
  17.  
  18.  
  19. var score = document.getElementById('score'), count = 0;
  20.  
  21. function input () {
  22. var gegevenINPUT = (document.querySelector('input').value);
  23. return gegevenINPUT;
  24. }
  25.  
  26.  
  27. function verwerkFormulier(event) {
  28. event.preventDefault();
  29. console.log('given answer '+ input());
  30.  
  31. if (input() == pick()) {
  32. count +=1;
  33. score.innerHTML = 'Score ' + count;
  34. console.log('Your score has been updated');
  35.  
  36. }
  37.  
  38.  
  39. }
  40.  
  41. document.querySelector('form').addEventListener('submit', verwerkFormulier);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement