I believe I am having issues with the storing of my id's in to an array for my simon game

I believe I am having issues with the storing of my id's in to an array for my simon game
0

#1

Hello I am having trouble with the check player against simon portion of my code. The code runs well until that player/checking part.Any suggestions /help with what I did wrong (I think the storing of id’s into my array is the problem ). Any suggestion I will be very thankful for

function clean(){
player=0;
store();
}
function store (){
if (player.length>=simon.length){
fight ();
}
}

function fight( ){

if(player.concat (simon)!==simon.concat (player) && $( ":checkbox" ).is( ":checked" ) ){
alert ("GAME OVER! press restart");
}
else if(player.concat (simon)!==simon.concat (player) {
alert("Try Again! Pick your self up from your bootstraps and try it again slugger!");
rabbit ();
}
else if( player.concat (simon)===simon.concat (player) && round===20){
$("h1").html ("WAY TO GO, SMARTY PANTS");
alert("YAY! YOU WIN! press restart");
}
else { 
begin();
}
}

I already have functions that pushes the player’s array in the happily running portion of my code like so :

function shoulders (){

  $("#shoulders").css ("background-color","cyan");
track3.play();
    setTimeout(function() {
        $("#shoulders").css("background-color","");
    }, 300);
}
$("#shoulders").click (function (){
player.push ("#shoulders");
shoulders();
})

#2

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

The issue is that you’re trying to compare two array variables to see if they’re equal, but it doesn’t work the way you’re expecting. Check this out: