my code is working creating a line diagonally forward and down but the light color never changes, it always just stays red. Can anyone help me fix this? BTW the red part is from earlier in the code meaning that none of the if statements are working in the loop
the code controls the lights on the right side of the house
function lightsDown(x,y,ln,s) {
for (u = 0; u < ln; u++) {
var c = random(1,4)
if (c === 1) {
fill('green')
}
if (c === 2) {
fill ('red')
}
if (c === 3) {
fill('yellow')
}
if (c === 4) {
fill('blue')
}
circle((x+4.5*s)-(2.67*s/ln)*u,y-(2.67*s/ln*u), s/4)
}
}
>Solution :
You’re condition on the if statement seems wrong. It should be (c === 1). And converting the variable c to int.