Loop function executed onclick JavaScript

Hi guys i’m trying to create a loop function so that each time the button is clicked the content will change. Where am I going wrong? right now it’s going to changeTestimonial2 when I click the button (the last in the loop)

function arrayOfTestimonials() {
    var arrayOfFunctions = [];

    for (var i = 0; i < arrayOfFunctions.length; ++i) {
        arrayOfFunctions[i](); // run your function

75 thoughts on “Loop function executed onclick JavaScript”

Leave a Comment