The purpose of the code is to allow users to play the game as many times as they want. I keep on getting stuck in infinite loop and I am not sure why. P.s. I need to stick to switch statements.
var color1 = prompt('Pick a color');
while (true){
switch (color1) {
case (color1 = 'blue'):
document.write("nope");
break;
case (color1 = 'yellow'):
document.write("nope");
break;
case (color1 = 'white'):
document.write("nope");
break;
case (color1 = 'gray'):
document.write("nope");
break;
case (color1 = 'green'):
document.write("yes");
break;
case (color1 = 'pink'):
document.write("nope");
break;
case(color1 = 'purple'):
document.write("nope");
break;
case (color1 = 'orange'):
document.write("nope");
break;
case (color1 = 'green'):
document.write("nope");
break;
case (color1 = 'magenta'):
document.write("nope");
break;
case (color1 = 'red'):
document.write("nope");
break;
}
if(color1 = false)
alert('Thanks')
}
==to test for equality instead of assignment=. Socolor1 =...should becolor1 ==...