2021年4月2日星期五

comparing the resulting "blocks" object with a list

Hi!

I've read literally all the articles about using map, filter, and includes in JS, but I still can't figure out how to get the "block"I need from the checks I received and passed.

Task: Inside object A, there are arrays that have the "block" field. This field should be compared with array B and the resulting values saved or simply returned.

First I got the unique values and combined them, and then I started searching in the resulting list, comparing them.

a = [     {      "id":1,      "title":"123",       "url":"123",       "password":"123",       "totp":"none",       "block":"none",       "created_at":"2021-03-28T20:36:21.000Z",       "updated_at":"2021-03-28T20:36:21.000Z"     },    {      "id":2,       "title":"qwe",      "url":"qwe",      "password":"qwe",      "totp":"none",      "block":"none",      "created_at":"2021-03-28T20:36:39.000Z",      "updated_at":"2021-03-28T20:36:39.000Z"    },    {      "id":3,      "title":"asd",      "url":"asd",      "password":"asd",      "totp":"none",      "block":"nne",      "created_at":"2021-03-28T20:36:42.000Z",      "updated_at":"2021-03-28T20:36:42.000Z"    }  ];         b = ['none', '5235', '5235']              console.log(    Array.from(a,       ({block}) => block    )    .map(      i => i    )    .map(      al => b.filter(        bal => bal === al      )    )  )  

Output: enter image description here

But I would like to see instead of the matched words - the specific objects to which these words belong

https://stackoverflow.com/questions/66922248/comparing-the-resulting-blocks-object-with-a-list April 03, 2021 at 12:21AM

没有评论:

发表评论