I've got an array filled with objects
const myArr = [
{k1: 1, k2: 1, k3: 3, k4: 4},
{k1: 1, k2: 2, k3: 3, k4: 4},
{k1: 1, k2: 2, k3: 3, k4: 4},
{k1: 1, k2: 2, k3: 3, k4: 4}
]
I'm attempting to filter these objects, although I don't necessarily have to use the "filter" method.
const filteredObj = myArr.filter(item => item.k2 === 1)
However, I only want to retain one specific key-value pair. For example,
console.log(myArr) => {k2: 1}