Filter objects in an array

Options
pachocastillosr
pachocastillosr Member
edited May 2023 in ? Help! I'm a Noob

Hi,

I am getting an array of products (json objects) as response from an external api call:

Example:

products =
[
{
id: 1,
name: 'Product 1',
price: 9.99,
description: 'Description of product 1'
},

{
id: 2,
name: 'Product 2',
price: 19.99,
description: 'Description of product 2'
}
]

I'd like to create a new array containing only the json objects of the products with price > 10 and empty description.

How can I do this?

Thanks!

Best Answer