I have an array words and it has words in it. I want to display say ‘N’ number of words per second. I wrote the code below and it is working for the first instance only. Please let me know.
tempstr = "";
for(k=0;k<grupof;k++)
tempstr += words[k] + " ";
i = grupof;
jQuery(document).ready(function(){
(function insertArray(){
$("p").text(tempstr);
if(i <words.length){
setTimeout(insertArray, 2000);
tempstr = "";
for(j=i;j<grupof;j++)
tempstr += words[j] + " ";
i = j;
}
})();
});
Here is the jsfiddle demo: http://jsfiddle.net/Skg7d/2/
needs to be