Variable changing to true before setInterval is finished

showMoves is a function made to show flashing for a simon game.

When the flashing lights are over I clear the interval to stop it and then I set game.playerTurn to true so I can click on colors, but game.playerTurn is changing to true as soon as showMoves is activated.

I want game.playerTurn to stay false until the showMoves function is finished showing flashing.

Here are the functions I’m using game.playerTurn in -

game.playerTurn = false;
function showMoves() {
 let i = 0;

 const start = setInterval(function() {
     if (i >= game.computerMoves.length) {
         clearInterval(start);
         game.playerTurn = true;
         return;
     }

     const move = game.computerMoves[i];
     setLight(move, true);
     setTimeout(setLight.bind(null, move, false), 1000); //Using bind to preset arguments
     
     i++;
 }, 2000);
}

function setLight(color, isOn) {
 if(isOn){
   sounds[color.id].play();
 }
 color.style.backgroundColor = isOn ? colors[0].get(color) : colors[1].get(color);
}

//activates after every click by player
function compareMoves(e){
 if(e === game.computerMoves[game.counter]){
   game.counter++;
   if(game.playerMoves.length === game.computerMoves.length && e === game.computerMoves[game.computerMoves.length-1]){
     simonHTML.displayScore.textContent = ++game.score;
     game.playerMoves = false;
     resetMoves();
     randomMoves(++game.turn);
     showMoves();
     game.counter = 0;
   }
 } else if(game.strict) {

 } else {
   game.playerMoves = [];
   game.counter = 0;
   game.playerMoves = false;
   showMoves();
   return false;
 }
}

I’d appreciate any help with this. Here is a link to the game and all the code https://codepen.io/icewizard/pen/JLBpNQ

I just found that if I put game.playerTurn to false inside of showMoves it works how I want it to

function showMoves() {
  game.playerTurn = false;
  let i = 0;

  const start = setInterval(function() {
  if (i >= game.computerMoves.length) {
      clearInterval(start);
      game.playerTurn = true;
      return;
  }

  const move = game.computerMoves[i];
  setLight(move, true);
  setTimeout(setLight.bind(null, move, false), 1000); //Using bind to preset arguments

  i++;
}, 2000);
}

I’m not sure why it doesn’t work this way when I place game.playerTurn to false in my compareMoves function though.