Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*jslint browser: true, devel: true, eqeq: true, plusplus: true, sloppy: true, vars: true, white: true*/
- /*eslint-env browser*/
- /*eslint 'no-console': 0*/
- function pick() {
- var imgArray = ['kabutops.png', 'wobbuffet.png','articuno.png'];
- var rand = imgArray[Math.floor(Math.random() * imgArray.length)]; //Pak een random naam uit de lijst
- document.querySelectorAll('img')[0].src = 'images/' + rand;
- var remove = rand;
- var keuze1= remove.substr(0, remove.lastIndexOf('.'));
- console.log('Random pick ' + keuze1);
- return keuze1;
- }
- pick();
- var score = document.getElementById('score'), count = 0;
- function input () {
- var gegevenINPUT = (document.querySelector('input').value);
- return gegevenINPUT;
- }
- function verwerkFormulier(event) {
- event.preventDefault();
- console.log('given answer '+ input());
- if (input() == pick()) {
- count +=1;
- score.innerHTML = 'Score ' + count;
- console.log('Your score has been updated');
- }
- }
- document.querySelector('form').addEventListener('submit', verwerkFormulier);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement