When declaring a variable:
var userChoice = prompt("Выберите цвет: красный, зеленый или синий"); you need to make sure that when a person chooses a color, say “red”, a certain action was performed, and if he writes, let’s say “black”, then the color selection window pops up until the person chooses a color from the suggested ones, or click Cancel. .
How many tried can not do it. Reached such a form, now I can not understand how to compare the variable userChoice with the values of the array.
var userChoice = prompt("Выберите цвет: красный, зеленый или синий"); var choiсes = ["красный", "зеленый", "синий"]; while (userChoice != "красный"){ var userChoice = prompt("Выберите цвет: красный, зеленый или синий"); };