In my node.js project, I have an array named products
that is structured as follows:
[ { product_id: 'adidas-training-shoes',
title: 'Adidas Training Shoes',
description: 'description',
brand: 'brand',
variants: [ [Object], [Object] ],
thumbnail_url: 'url' },
{ product_id: 'nike-running-shoes',
title: 'Nike Running Shoes',
description: 'description',
brand: 'brand',
variants: [ [Object], [Object], [Object], [Object] ],
thumbnail_url: 'url' },
{ product_id: 'vans-sneakers',
title: 'Vans Sneakers',
description: 'description',
brand: 'brand',
variants: [ [Object], [Object], [Object] ],
thumbnail_url: 'url' } ]
Additionally, I have a configuration file named config.json that includes a list of keywords along with other settings:
{
"keywords": [
"vans",
"nike" ]
}
I aim to filter the products
array using products.filter()
to retrieve the items whose product.title
contains any of the keywords listed in config.keywords
.
I am relatively new to JavaScript, especially ES6, and I'm open to switching to a different version if it simplifies the process. Despite conducting research prior to posting this question, I hope it offers a unique perspective on the issue at hand.