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