Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const data = [
- {
- name: "john",
- age: 2
- },
- {
- name: "alice",
- age: 10
- },
- {
- name: "james",
- age: 10
- }
- ]
- }]
- const target = ['alice', 'james']
- const r = data.map(obj =>
- target.includes(obj.name) ? { qualified: true, ...obj } : obj
- )
- console.log(r)
Add Comment
Please, Sign In to add comment