Is there a way to create a loop or function that can show a new array index every time it is clicked? I attempted using a for loop, but it only displays the first value and then jumps to the last value when clicked again.
var arrow = document.getElementById ('arrow');
var para = document.getElementById ('para');
function textForward (){
arrow.addEventListener('click', function(){
var arr = [
'a','b','c','d'
]
for (var i = 0; i < arr.length; i++)
para.innerHTML = arr[i]
});
}
On each click of a button, the above code should display the next value of the array in sequence. For instance, starting with 'a' and progressing to 'b' upon the user's click, followed by 'c' on the subsequent click, and so forth.