em-wilson / book-node-mongodb-backbone

Example source code accompanying O'Reilly's "Building Node Applications with MongoDB and Backbone" by Mike Wilson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hasContact() function

cjuhong opened this issue · comments

var hasContact = function(account, contactId) {
if ( null == account.contacts ) return false;

account.contacts.forEach(function(contact) {
  if ( contact.accountId == contactId ) {
    return true;
  }
});
return false;

};

in chapter08, the hasContact function would never return true!!!

the forEach method is not suitable for this situation.