Question: In Javascript, how do you check if the user's input is one of the elements in an array? I want to print an error message
In Javascript, how do you check if the user's input is one of the elements in an array? I want to print an error message if it is not.
e.g.
var numbers = [1, 2, 3, 4]
var choice = parseint(prompt("Enter a number between 1-4")
// if the choice is not in numbers, I want to print an error message
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
