I can't figure it out and i feel like this is messing with my code in a larger scope. Shouldn't it just be dead 0? What am i missing?
var opacity = 1;
function FadeOut()
{
fadeOutTimer = setInterval(() => {
console.log(opacity);
if (opacity <= 0)
{
opacity = 1;
clearTimeout(fadeOutTimer);
return;
}
opacity = (opacity <= 0) ? 0 : opacity - 0.1;
}, 15);
}
<button onclick="FadeOut()" type="button">
Test
</button>