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