Created
July 9, 2018 21:38
-
-
Save mittsh/cdf344c5d5c2821b6813c62a31bc42d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// restaurants are loaded... | |
var restaurants = [ | |
{ | |
"id": 324, | |
"name": "Tien Hiang", | |
}, | |
{ | |
"id": 329, | |
"name": "Hank Burger", | |
}, | |
… | |
]; | |
/* | |
* Finds a restaurant by its given ID. | |
* | |
* @param restaurantId The restaurant identifier to lookup. | |
* @return Returns a restaurant object or null. | |
*/ | |
var findRestaurantById(restaurantId) { | |
for (var i = 0; i < restaurants.length; i++) { | |
if (restaurants[i] === restaurantId) { | |
return restaurants[i]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment