Ask your JavaScript questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to get 'quantity' of fruit.name === 'apples' JavaScript

  • REFUNDED

How to get 'quantity' of fruit.name === 'apples' Note that the program stops if the target record doesn't exist. I need to fix that, too. Check for name == 'apples' somehow.



search term = "apples";

const fruits = [
{name: 'apples', quantity: 2},
{name: 'bananas', quantity: 0},
{name: 'cherries', quantity: 5}
];

const getFruit = fruits.find(fruit => fruit.name === searchterm);

console.log(getFruit);

Answers (0)

No answers yet.