trying to matching two arrays with filter

Viewed 18

i have two arrays, the finished array, which is

const finished = [ 'Pablo', 'mauro', '12/09/2022', '18:00', 'corte cabelo' ]

and another one, calldes users, which is

const users  = [

{
    name: 'Pablo',
    professional: 'mauro',
    date: '12/09/2022',
    hour: '18:00',
    service: 'corte cabelo'
  }
]

and im create another one, to see if got a match value

const isValid = users.filter(
                (user) =>
                    user.professional === finished[1] &&
                    user.date === finished[2] &&
                    user.hour === finished[2],
            );

but even when i have a match the output of the array isValid always are an empty array.

[]

I want that when there is a match, it returns to me in a new array. What am I doing wrong?

i tried also includes, but want to see if are match inner the obj inside the array

0 Answers
Related