+ 3

Why when I delete "if" it work's good but when I write it again the value of input is always black??

https://code.sololearn.com/Wj6qAvFryVqZ/?ref=app

11th Jun 2018, 11:52 PM
Sina
Sina - avatar
5 Answers
+ 6
You need == for your if. Using single = assigns "black" every time. Also, all of the statements are missing semicolons.
12th Jun 2018, 12:01 AM
Tamra
Tamra - avatar
+ 6
Sina try if(y.value === "black") P.S. I tried Tamra suggestion and it seemed to work also.
12th Jun 2018, 12:24 AM
Ipang
+ 5
Sina The code works on my phone using both == and ===. It doesn't if y.value different in capital e.g. "Black", that doesn't work. Try if(y.value.toLowerCase() === "black") this will compare the color value in lowercase, maybe it works : )
12th Jun 2018, 3:06 AM
Ipang
+ 2
See I want when the background color is black the style of "p" get's white
12th Jun 2018, 1:48 AM
Sina
Sina - avatar
+ 1
When I use == it doesn't work. try it to see
12th Jun 2018, 12:07 AM
Sina
Sina - avatar