I'm having a problem with my function. It's a function made to display every word of an array one bye one, for one second, when you press a button, but for some reason it tells me I'm calling too much, despite making sure to put a loop to check if it can be called. Here it is
var liste = ["one", "two", "three", "four", "five"]; //Changer la liste par la liste de syllabes qu'on veut travailler. Je ne sais pas encore comment l'importer d'un fichier txt
var text = document.getElementById("myText");
var btn = document.getElementById("myBtn");
btn.addEventListener("click", showsyll(liste));
function showsyll(arr) {
var i=0;
if (i < arr.length) {
text.innerHTML= arr[i++];
setTimeout(showsyll(arr), 1000);
}
else {
return
}
}
The html part is super simple, just a button and a text id
<p id="myText"></p>
<button type="button" id="myBtn">Press to show syllables</button>