+ 1

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"); } }); }

11th Jun 2018, 10:05 AM
lakdhi ubhayaratna
lakdhi ubhayaratna - avatar
4 Respuestas
+ 3
write here a href to your code on SoloLearn PlayGround
11th Jun 2018, 10:54 AM
Dmitriy
Dmitriy - avatar
11th Jun 2018, 11:18 AM
lakdhi ubhayaratna
lakdhi ubhayaratna - avatar
0
i am pretty much stuck with this one please help me to find those and way to fix this the project name is color pick and i donno how to link that reference to here
11th Jun 2018, 11:14 AM
lakdhi ubhayaratna
lakdhi ubhayaratna - avatar
0
lakdhi ubhayaratna wrap the script around window.onload function. https://www.sololearn.com/post/7444/?ref=app
11th Jun 2018, 12:29 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar