So, I have a few a strings loaded into an array called messages. I want to cycle through the messages with a half second period where no message is showing. My code should do that, but for whatever reason it doesn't. No text shows at all.
Here is my code:
        function NextElement()
        {
            var x = messages.shift();
            messages.push(x);
            return x;
        }
        function doer()
        {
            $("p.message").text(NextElement());
        }
        function doer2()
        {
            $("p.message").text("");
        }
        $( document ).ready(function() 
        {
         setInterval( doer,1000);
         setTimeout(function() {}, 500);
         setInterval( doer2,1000);
        });
If if remove this line
       $("p.message").text("");
messages show, but don't disappear after half a second.
I was looking at this page for how timeout works and perhaps I misunderstood. It seems it doesn't work the same way as thread.sleep() does in Java/C#
 
     
     
    