Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Finding whether a value inputted by user exists in the given array
var fruits = ['apples', 'pears', 'bananas'];
console.log("Enter in a fruit name");
process.stdin.on('data', function(fruit) {
var fruitName = fruit.toString().replace("\n", "");
if (fruits.indexOf(fruitName) >= 0 ) {
console.log("The value has been found in the array");
process.exit(); }
else {
console.log("Value not found");
process.exit(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.