Everything Be True

题目:

完善编辑器中的every函数,如果集合(collection)中的所有对象都存在对应的属性(pre),并且属性(pre)对应的值为真。函数返回ture。反之,返回false。

记住:你只能通过中括号来访问对象的变量属性(pre)。

代码:

1 function every(collection, pre) {
2   var result=collection.every(function(obj){
3     return obj[pre];
4   });
5   return result;
6 }
原文地址:https://www.cnblogs.com/hiker90/p/6800686.html