How would I get the name of an item from an array such as the one below, using an id? I have tried by using the .find function in javascript but it returns an undefined response.
{
    "products": [
        {
            "name": "Blue T-Shirt",
            "price": 25.99,
            "description": "A lovely t-shirt.",
            "image": "tshirt.png",
            "id": 1
        },
        {
            "name": "Beige",
            "price": 16.49,
            "description": "Some nice beige pants.",
            "image": "pants.png",
            "id": 2
        },
        {
            "name": "Ugly Shirt",
            "price": 27.99,
            "description": "An ugly, gag-gift shirt.",
            "image": "shirt.png",
            "id": 3
        }
    ]
}
and this is how I am finding it:
var slug = req.params.product;
var item = products.find(products => products.id === slug).name;
console.log(item);
Thanks in advance!
 
    