Need Help | Simon Says highlight and pausing issue

I am need help figuring out how to get my Simon Says game to pause after the button/color is selected, so that users are able to view the sequence of buttons to push. It also needs to pause so that the sound can play as well. I really want to create a function that pauses or delays my code long enough for the highlight and sound plays. I am pretty sure I need to put this pause in two places in my code, see below:

  function randomPlay(){  
    for (i=0; i<order.length; i++){
    if(order[i] == 1){
        color = "red";
      }else if (order[i] == 2){
        color = "blue";
      }else if (order[i] == 3){
        color = "green"; 
      }else if (order[i] == 4){
        color = "yellow";
       !!pause here!!

  function nextTurn(){
    count += 1;
    check = [];
  !!pause here!!

Please let me know if I am on the right track or need to revamp my coding. Thanks in advance.

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


Thank you, I will remember this in the future.