can someone point out/correct me, why the progress bar won't subtract the current value from the max value? The goal is based on the condition I set, if it reaches above the max value, then current value - max value and the progress bar should be 10.
<progress id="counter" max="100" value="0"></progress>
<button onclick="add()">
add + 10
</button>
<p id="counterText">
0
</p>
function add() {
var counterMax = document.getElementById('counter').max;
var counterVal = document.getElementById('counter').value;
var counterText = document.getElementById('counterText');
var counterAdd = document.getElementById('counter').value = counterVal + 10;
counterText.innerHTML = counterAdd;
if(counterVal > counterMax) {
var counterTotal = document.getElementById('counter').value = counterAdd - counterMax;
counterText.innerHTML = counterToTal
}
}