I’m at the point in programming my game where simon shows his pattern, but my trigger to fire clicks is not working I would be very greatful for any help. I am feeling discouraged right now that I am not able to figure it out at this moment.
var track3 = new Audio();
track3.src = ‘https://s3.amazonaws.com/freecodecamp/simonSound1.mp3’;
var head= $("#head").click (function (){
$("#head").css (“background-color”,“black”);
$("#head").css({ opacity: 0.9});
track3.play ();
setTimeout(function() {
$("#head").css({ opacity: 0.0 });
$("#head").css(“background-color”,"");
}, 300);
});
var shoulders= $("#shoulders").click (function (){
$("#shoulders").css (“background-color”,“cyan”);
track3.play();
setTimeout(function() {
$("#shoulders").css(“background-color”,"");
}, 300);
});
var knees= $("#knees").click (function (){
$("#knees").css (“background-color”,“mediumPurple”);
track3.play ();
setTimeout(function() {
$("#knees").css(“background-color”, “”);
}, 300);
});
var toes= $("#toes").click (function (){
$("#toes").css (“background-color”,“mediumSpringGreen”);
track3.play();
setTimeout(function() {
$("#toes").css(“background-color”, “”);
}, 300);
})
var round= 0;
var player= [ ];
var simon=[ ];
var pat= [“head”, “shoulders”, “knees”, “toes”];
$(".start").click(function (){
simon=[ ];
player=[ ];
round=[ ];
additionalRound();
})
function additionalRound(){
round ++;
$(“h2”).html(“Round:” +round);
setTimeout(function() {
$(“h2”).html(“HEAD, SHOULDERS, KNEES, AND TOES!”);
},2660);
sequence();
}
function sequence (){
simon.push(pat[Math.floor (Math.random ()*4 )]);
blinkerBeats ();
}
function blinkerBeats() {
for (var i = 0; i < simon.length; i++) {
setTimeout(function() {
$(simon[i]).trigger(‘click’);
}, i * 800);
}
}