I have an array with 58112 words. However, when I try to check if a word is in the list, it always returns false, except for the first word. I'm not going to post my code because that would be too large, but here is some of the main stuff:
isWord("a") //true
isWord("hello") //false??
function isWord(word) {
word = word.toLowerCase();
for (let i = 0; i < words.length; i++) {
if (word == words[i]) {
return true;
} else {
return false;
}
}
}
words[] is the list of 58112 words. The first word is "a", of course. When I do isWord("a"), it returns true, like expected. If I do anything other than "a", It returns false. Why does this occur? Is it because I exceeded the maximum array limit? I don't think so.
The words I used are from this (I had to add the "a" and the "i" because they didn't have one).