Lets say we have a simple scenario where I would like to repeatedly output "Hello" followed by "World" 1 second later. I have tried the following:
setInterval(
function() {
console.log("Hello");
setTimeout(
function() {
console.log("World");
},
1000
);
},
1000
);
But it doesn't work, at the second interation of setInterval
the console.log
outputs Hello World at the same time.
What did I do wrong?