function every(collection, pre) {
  // Is everyone being true?
  //return pre;
  for(var i in collection){
    if(!collection[i][pre]){
      return false;
    }
  }
  return true;
}

every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");

  

posted on 2016-12-21 17:44  梦如影  阅读(209)  评论(0编辑  收藏  举报