javascript find 28 29 array method

Solutions on MaxInterview for javascript find 28 29 array method by the best coders in the world

showing results for - "javascript find 28 29 array method"
Imen
23 Feb 2018
1const employees = [
2 { name: "David Carlson", age: 30 },
3 { name: "John Cena", age: 34 },
4 { name: "Mike Sheridan", age: 25 },
5 { name: "John Carte", age: 50 }
6];
7
8let user;
9
10for(let i = 0; i < employees.length; i++) {
11  if(employees[i].name.indexOf('John') > -1) {
12    user = employees[i];
13    break;
14  }
15}
16
17console.log(user); // { name: "John Cena", age: 34 }
18