# Find the right object in array and assert on it

**URL:** <https://community.postman.com/t/find-the-right-object-in-array-and-assert-on-it/34244>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [April 5, 2022, 5:27pm UTC](https://community.postman.com/t/find-the-right-object-in-array-and-assert-on-it/34244 "2022-04-05T17:27:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 5, 2022, 6:01pm UTC](https://community.postman.com/t/find-the-right-object-in-array-and-assert-on-it/34244/2 "2022-04-05T18:01:04Z")

</div>

You could use something like:

```auto
let obj = pm.response.json().users.find(e => e.name === 'Julius');
console.log(obj.pet);

```

You could use that function inside a test and expect against `obj.pet` to equal `iguana`.

For example:

```auto
pm.test('Name of pet matches', () => {
    let obj = pm.response.json().users.find(e => e.name === 'Julius');
    pm.expect(obj.pet).to.eql('iguana');    
});
```

---

_[View the full topic](https://community.postman.com/t/find-the-right-object-in-array-and-assert-on-it/34244)._
