I have a JSON array that looks like this:
['Monkey','Cheetah','Elephant','Lizard','Spider']
I also have a text input. I want to test whether the value of the input upon 'blur' is also in the array and if it is do something.
Knowing a bit of python I tried something like this:
var existing_animals = ['Monkey','Cheetah','Elephant','Lizard','Spider']
$('input').blur(function() {
user_animal = $(this).val()
if (user_animal in existing_animals) {
alert('Animal already exists!')
}
});
So, how rookie is my mistake?