Im trying to make a function where I change the background color to the color that is input. It seems like the function works but it only changes to yellow. It leads me to believe that theres something wrong with the if else statements but I cant figure it out.
var colore = document.getElementById("colors");
function changecolor() {
if (colore = "yellow"){
document.body.style.backgroundColor = "yellow";
}else if (colore = "blue"){
document.body.style.backgroundColor = "blue";
}else if (colore = "green"){
document.body.style.backgroundColor = "green";
}else if (colore = "black"){
document.body.style.backgroundColor = "black";
}else {document.getElementById("error").innerHTML =
"Enter a Valid Color";}
}