1var arr = [{ id: 1, name: 'JOHN' },
2 { id: 2, name: 'JENNIE'},
3 { id: 3, name: 'JENNAH' }];
4
5function userExists(name) {
6 return arr.some(function(el) {
7 return el.name === name;
8 });
9}
10
11console.log(userExists('JOHN')); // true
12console.log(userExists('JUMBO')); // false
1var arr = [{ id: 1, username: 'fred' },
2 { id: 2, username: 'bill'},
3 { id: 3, username: 'ted' }];
4
5function userExists(username) {
6 return arr.some(function(el) {
7 return el.username === username;
8 });
9}
10
11console.log(userExists('fred')); // true
12console.log(userExists('bred')); // false
13