0

I am trying to use find function in this array

array=  [{
        type: 'banks',
        id: 25,
        attributes: { name: 'Bradescard', bankNumber: '063' },
        links: { self: '/banks/63' }
      },
      {
        type: 'banks',
        id: 26,
        attributes: { name: 'BM Goldman Sachs', bankNumber: '064' },
        links: { self: '/banks/64' }
      },
      {
        type: 'banks',
        id: 27,
        attributes: { name: 'Bracce', bankNumber: '065' },
        links: { self: '/banks/65' }
      }
    ]

if I try find(propEq('id', 27))(array) it returns the correct object, but I need to find by bankNumber.

I tried find(propEq(lensPath(['attributes', 'bankNumber']), '065'))(array) but I got undefined

How can I do this?

1 Answer 1

3

Try to just switch propEq to pathEq.

Something like: find(pathEq(['attributes', 'bankNumber'], '065'))(array).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.