function getPrice(name) { prices.forEach(function (el) { if (el.name == name) { return el.price; } else { return null } }); }