How to filter an object in a JavaScript array

Let's assume that we define the following array of objects:

let tees = [
        color: 'pink',
        price: 10
        color: 'red',
        price: 20
        color: 'black',
        price: 30

If we want to filter an object in the array depending on the color:

// We filter the pink tee
let filtered = tees.filter(tee => tee.color === 'pink');

// We get the first element of the filtered array
let tee = filtered[0];

// {color: 'pink', price: 10}

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.