Hi I'm trying to create a small workout app. The app displays an exercise and a counter. I want to make the count reach the specified number (20), then have the loop move onto and display the next exercise in the array and reset the count back to 0. I'd like it to repeat this until all the exercises in the array have been displayed.
I would also really appreciate someone telling me where this went wrong.
link : https://codepen.io/jtog95/pen/zYrMpPB
var increasing = true;
var excercises = document.getElementById('exercises');
var counter = document.getElementById('counter');
var count = 0;
var specifiedNum = 20;
var exerciseList = ['Push-ups', 'Pulls-ups', 'Squats', 'Curls'];
var fnLoop = setInterval(exerciseLoop, 20000);
function exerciseLoop(){
for(var i = 0; i < exerciseList.length; i++){
exerciseList[i] = excercises.innerHTML;
increasing === true ? count++ : count = 0;
count = counter.innerHTML;
if(count === specifiedNum) {
count = 0;
exerciseList[i] += 1;
clearInterval(fnLoop);
}
}
}
<div class="counter-container">
<div id= 'counter' class="counter">0</div>
</div>
<div class="exercisecontainer">
<div class="currentexercise">Current Exercise: </div>
<div id= 'exercises' class="exercises">Push-Ups</div>
</div>
<div class="buttoncontainer">
<button id='start' class='start button'>Start</button>
<button id='stop' class='stop button'>Stop</button>
</div>
delay. Define a counter before the reduce function and used it to identify the node list nodeList[i] then your totaldelay will need to increment += delay...