i cant find the error here can u guys please help me
I just want the match the clicked square color with picked square color? console.log("connected"); var colors = [ "rgb(255,0,0)", "rgb(255,255,0)", "rgb(0,255,0)", "rgb(0,255,255)", "rgb(0,0,255)", "rgb(255,0,255)" ]; var squares = document.querySelectorAll(".square"); var pickedColor = colors[0]; var colorDisplay = document.querySelector("#colorDisplay"); colorDisplay.textContent = pickedColor; for (var i = 0; i < squares.length; i++) { //adding inital colors squares[i].style.background = colors[i]; //4.adding the logic to the event click lisnters squares[i].addEventListener("click", function() { // 5.grap the color of picked square var clickedColor = this.style.background; console.log(clickedColor);//click karapu eka console.log(pickedColor);// choose karapu ekaa //6. compare them with the picked color if (clickedColor === pickedColor) { console.log("correct"); }else{ console.log("try again"); } }); }