logo
logo

Check If Any Object Has a Certain Property using some()

Beginner

Check If Any Object Has a Certain Property using some()

Write a function
checkAnyHasProperty
that takes an array of objects as input, and a property name as a string, and returns a boolean indicating whether any of the objects in the array have that property using the
some()
method.
const arr = [
  {name: 'John', age: 30},
  {name: 'Mary', age: 25},
  {name: 'Bob', salary: 50000}
];

checkAnyHasProperty(arr, 'salary'); // true

Console
Submit
Solution
00:00