Skip to content

Instantly share code, notes, and snippets.

@whereisciao
Created November 30, 2011 23:19
Show Gist options
  • Save whereisciao/1411788 to your computer and use it in GitHub Desktop.
Save whereisciao/1411788 to your computer and use it in GitHub Desktop.
Return the GPS coordinates of a house.
var PASSENGERS = [
{
username: "achang88",
name: "Alex Chang",
house: "Kirkland House"
},
{
username: "afaux",
name: "Ainsley Faux",
house: "Adams House"
},
{
username: "agore",
name: "Al Gore",
house: "Dunster House"
}
];
var HOUSES = {
"Adams House": {lat: 42.37189, lng: -71.11639},
"Cabot House": {lat: 42.381842, lng: -71.123857},
"Currier House": {lat: 42.381704, lng: -71.125773}
}
for(i in PASSENGERS) {
var passenger = PASSENGERS[i];
var house = HOUSES[passenger.house];
console.log(passenger.name + " " + passenger.house);
if(house != undefined){
console.log("("+ house.lat +", "+house.lng+")")
} else {
console.log("(Unknown GPS)")
}
}
/*
* Output
Alex Chang Kirkland House
(Unknown GPS)
Ainsley Faux Adams House
(42.37189, -71.11639)
Al Gore Dunster House
(Unknown GPS)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment