JSFiddle - React, Tailwind, and code Playground
JavaScript
var moves = [{playerName:'Test'},{playerName:'Terry'}, {playerName:'sdfsdf'}];
var currIdx = 0;
var intervalId = window.setInterval(function () {
var playerName = moves[currIdx].playerName;
console.log("Inside for loop"+ playerName);
(function(name) {
setTimeout(function(){
console.log("Inside set time out :"+name);
},0);
})(playerName);
currIdx++;
if(currIdx >= moves.length)
window.clearTimeout(intervalId);
}, 10);