So I have volume up and down buttons that displays a notification every time the volume is increased.
Volume Up
function volumeUp() {
if (currentVolume < .9) {
currentVolume += .1;
sound.volume = currentVolume;
var $toastContent = $('<span>Volume '+ parseInt(currentVolume * 100)+ ' %' + '</span>' );
Materialize.toast($toastContent, 2000);
} else {
alert("Max Vol")
}
}
Volume Down
function volumeDown() {
if (currentVolume > .1) {
currentVolume -= .1;
sound.volume = currentVolume;
var $toastContent = $('<span>Volume '+ parseInt(currentVolume * 100)+ ' %' + '</span>' );
Materialize.toast($toastContent, 2000);
} else {
alert("Min Vol")
}
}
The problem I'm having is, when I get to < 80% it starts to alert as 89 then 99 instead of 90 and 100.
Also when I get to 10% and I decrease it, it shows as 2% not 0%.
Any ideas?
Thank you!