Script says Undefined

If the word is not in your array then you will get undefined. If you type “Bo” then you will get undefined because “Bo” is not in your array.

You are calling the script with the KeyPress event. If the user is trying to type Bob then this is what happens.

b — b is in array, no problem

bo — bo is not in array so undefined

bob — javascript bombs at bo so you don’t get this far.

Leave a Comment