Check if user inputted string is in the array in JavaScript



We are required to write a JavaScript program that provides the user an input to enter a string value.

The program should then check the input value against some hard-coded array values. Our program should print true to the screen if the input string value is included in the array, false otherwise.

Example

The code for this will be −




   
   
   CHECK EXISTENCE


   
   
   
   

Output

And the output on the screen will be −

Updated on: 2020-11-20T13:38:41+05:30

465 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements