The way you wrote this code, it should work. I made the test...
code
<body>
<script type="text/javascript">
console.log("test");
var fun1 = function(){
console.log("fun1");
}
var fun2 = function(){
console.log("fun2");
}
var fun3 = function(){
console.log("fun3");
}
function arrayOfTestimonials() {
var arrayOfFunctions = [];
arrayOfFunctions.push(fun1);
arrayOfFunctions.push(fun2);
arrayOfFunctions.push(fun3);
for (var i = 0; i < arrayOfFunctions.length; ++i) {
arrayOfFunctions[i](); // run your function
}
}
arrayOfTestimonials();
</script>
</body>
output
test
fun1
fun2
fun3
If you want to call function by function, you should do something like this...
<body>
<button onclick="onClickButton()">click me!</button>
<h2 id="title">No function has been called!</h2>
<script type="text/javascript">
var functionNumber = 1;
var fun1 = function(){
document.getElementById("title").innerHTML = "Function 1 has been called!";
}
var fun2 = function(){
document.getElementById("title").innerHTML = "Function 2 has been called!!";
}
var fun3 = function(){
document.getElementById("title").innerHTML = "Function 3 has been called!!!";
}
function onClickButton(){
if(functionNumber === 1){
fun1();
functionNumber++;
}else if(functionNumber === 2){
fun2();
functionNumber++;
}else if(functionNumber === 3){
fun3();
functionNumber = 1;
}
}
</script>
</body>
arrayOfTestimonials()function will call everything at once.