I’m missing some little thing.. prints the array but doesn’t wait in between lines.
<script type="text/javascript">
function showLines()
{
arr =
[
"Hi!",
"Welcome!",
"Hello!"
]
var duration=2000;
document.getElementById("quotes").innerHTML=arr;
setTimeout('showLines()',duration);
}
</script>
Most answers here are re initializing your array on each iteration.It makes no sense to do that. You should do it like this:
This way it works, and your array, and i are only initialized once.
EDIT In response to comment: