我尝试遍历整个数组并找出它们的“真实性”。现在,当我运行该函数时,我得到了一些undefined-result。:( 为什么?
myArray = [
{text: 'hola', done: false},
{text: 'hola', done: true},
{text: 'hola', done: true},
{text: 'hola', done: false},
{text: 'hola', done: true}
];
var howMany = function(myArray){
var result;
for (var item in myArray){
if(myArray.done === true)
result++;
}
return result;
};
var items =howMany(myArray);
console.log(items) // I want to see if it's correct