How to make an event fire every time, and once of, for example ten?

From hours wrote a script showing the logo only when you scroll the page
position: fixed; but it turns out somehow Intrusive, I would like to fire every time and
where once from destati.

window.onscroll = function ()
{
document.getElementById("logo").style.opacity= 1;
setTimeout(
function() {
document.getElementById("logo").style.opacity = 0;},
500);
}
September 26th 19 at 11:26
2 answers
September 26th 19 at 11:28
Solution
window.scrollTimes = 0;
window.onscroll = function () {
 if(window.scrollTimes < 10) {
window.scrollTimes++;
return;
}
 window.scrollTimes = 0;
 ... // Rest of code
}
September 26th 19 at 11:30
1. To receive the random number from 1 to 10.
2. If the number = one number A (1 to 10), then perform the function.

Find more questions by tags JavaScript