我知道有很多与此错误有关的问题,我已经检查了大部分问题,没有人帮我解决我的问题.(这似乎很容易调试......)
我有一个数组(首先是空的):
var words = [];
Run Code Online (Sandbox Code Playgroud)
我的函数hasLetter,检查我们是否在数组中找到一个字母(对象)(我在这里称之为:d)单词.
function hasLetter(letter,d){
// if words[0] not null should return object of letter "a", here we getting
// the index of the letter (since ascii of "a" is 97, I substract 97)
var ascii = letter.charCodeAt(0)-97;
//Trying to not get an error with this but still creates an err
if(typeof d[ascii ] !== "undefined" && d[ascii ] !== null && d[ascii ].length > 0){
if(d[ascii].letter == letter){
return true;
}
}
return false; } …Run Code Online (Sandbox Code Playgroud)