I am new to javascript and I am trying to make small exercises every day. I am having difficulty figuring out if it is possible to add a time delay to a for-loop. So when the code goes from one i to another it will wait one second.
I am trying to build a small program that plays sounds for each letter that user input. For example, for numbers, it will play a sound and another sound will be played for letters. It just has to wait one second when it goes from one i to another (i++) so the sounds are not played at once.
Thank you in advance.
function getText()
{
var myString=document.name1.ids.value;
var list3 = myString.split('')
var list1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
var list2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
for (var i = 0; i < list3.length; i++) {
if(list1.indexOf(list3[i]) >= 0){
audio.play();
}
else if(list2.indexOf(list3[i]) >= 0){
audio2.play();
}
else{
}
}
}