'get all hashes from array from hashes where values are true in javascript

I have an array of hashes as below. I want to get only those hashes where values are true

array = [{id:1, name: 'A'},{id: 2, name: 'B'},{id: 3, name: 'C'},{id:4, name: 'D'}]

values = [2, 4]

I only want those hashes where id is 2, 4



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source