What do you want to save?
Add Code snippet
New code examples
-
Other 2021-10-22 10:53:06
return the first matching object from an array
function priceLookup(items, name) { for (let i = 0; i < items.length; i++) { if (name === items[i].itemName) { // the return will break the loop and exit the function return items[i].price; } } // if loop completes no matches... Add solution
Best helpers
Mushi.f
+5
Ivan T.
+5
Bianco
+5
Nikola
+5
Graffito
+5
Mari Yoongi
+5
Tyr
+5
Christophrrb
+5
Vary
+5
Del Findley
+5
Ryan Friend
+5
Millemila
+5
Soumee
+5
Gftern
+5
Davesmiths
+5
Vocaro
+5
Vbence
+5