Created
January 21, 2015 13:12
-
-
Save JacobHsu/b8f216aa622cf89e6c74 to your computer and use it in GitHub Desktop.
#JS Object
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
var vehicle1 = {type: "Motorboat", capacity: 6, storedAt: "Ammunition Depot"}; | |
var vehicle2 = {type: "Jet Ski", capacity: 1, storedAt: "Reef Dock"}; | |
var vehicle3 = {type: "Submarine", capacity: 8, storedAt: "Underwater Outpost"}; | |
var vehicles = [vehicle1, vehicle2, vehicle3]; | |
var findVehicle = function (name, list){ | |
for(var i = 0; i<list.length; i++){ | |
if(list[i].type == name){ | |
return list[i].storedAt; | |
} | |
} | |
}; | |
findVehicle("Submarine", vehicles); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment