Finding an object

Report a typo

In the code below an array of objects is given to the search() function. Change it so that the function returns the index of the element, that has the following properties: key name with the value of "John" and key age with the value of 30.

Sample Input 1:

[{"name": "Ann", "age": 30}, {"name": "John", "age": 50}, {"name": "John", "age": 30}]

Sample Output 1:

2
Write a program in JavaScript
function search(objects) {
// Write your code here
}
___

Create a free account to access the full topic