Ich habe die Antwort auf eine vorherige Frage gefolgt, aber ich bekomme nicht die Ergebnisse. Ich bin eine Zufallszahl zu erzeugen und basierend auf der Anzahl, möchte ich 1 von vier Funktionen aufzurufen:JavaScript: Funktionen von einem Array aufrufen
var functionArray[single, double, triple, quadruple];
function main() {
ranNum = Math.floor(Math.random() * functionArray.length);
x = functionArray[ranNum](); /* is this the way to call the function? */
}
/* example of one function in the array */
function single() {
/* do stuff */
return x;
}
Was ist Ihr Problem hier mit dem Code –
var FunktionArray = [Einzel-, Doppel-, Dreifach-, Vierfach]; –