0

I'm trying to get something to run after a function using setInterval is done. I'm trying to do this with callbacks but I can't seem to get it work?

So far I have the following

        var testing = ['A','D','F','H','B'];
        var index = 0;
        var wordCount = 1; 

        var showHide = setInterval(function () {
            var displayWords = "";
            var mx = index + wordCount;
            if (mx > testing.length) mx = testing.length;
            for (var i = index; i < mx; i++) {
                displayWords += testing[i] + " ";
            }
            d3.select("#stim").text(displayWords).style("font-size","150px");
            index = mx;
            if (index > testing.length) {
                clearInterval(showHide); 
                d3.select("#stim").text('L,R').style("font-size","150px");

            }
        }, 1000);

And I want the following line to execute "after":

d3.select("#stim").text('L,R').style("font-size","150px");

I tried using this method but when I try to put "showHide" in its own function, it doesn't seem to work at all.

Community
  • 1
  • 1
gg4
  • 5
  • 3

0 Answers0