The add Event Listener Doesn't call the Play function and i don't understand why?
var btn = document.querySelector('#btn');
var title = document.querySelector('#title');
var count = 0, rand = 0 , sum =0;
var one = document.getElementById('one');
btn.addEventListener('click',play);
function play()
{
count = 8200;
this.rand = Math.floor(Math.random() *7)+1;
this.sum +=rand;
one.textContent = sum;
if(sum >= 100)
{
title.textContent = 'You won!'
}
}
I tried to debug id on Firefox debugger and it's show that it jump directly to the end of the code. why the play method doesn't execute?
Aucun commentaire:
Enregistrer un commentaire