Skip to content

Instantly share code, notes, and snippets.

@jdaly13
Created March 15, 2020 21:59
Show Gist options
  • Save jdaly13/6973d7ccd20ebd81751086739ff7f926 to your computer and use it in GitHub Desktop.
Save jdaly13/6973d7ccd20ebd81751086739ff7f926 to your computer and use it in GitHub Desktop.
classes javascript
function myFavoriteThingsEachCity (sport, landmark, food) {
const object = {};
object[this.constructor.name]= {
team: this.sportsTeams[sport],
landMarks: this.landmarks[landmark],
food: this.bestFoods[food]
}
return object
}
class StLouis {
constructor(areaCode) {
this.areaCode = areaCode;
this.sportsTeams = ["blues", "cardinals", "battlehawks"];
this.landmarks = ["The Gateway Arch", "City Musuem"];
this.bestFoods =["bbq", "sandwerches", "italian"]
}
favoriteSportsTeam(index) {
return this.sportsTeams[index];
}
favoriteThings(sport, landmark, food) {
// return myFavoriteThingsEachCity.call(this, sport, landmark, food)
}
}
const stLouis = new StLouis(314);
const favoriteTeam = stLouis.favoriteSportsTeam(2);
//console.log(stLouis.favoriteThings(2,0,0))
console.log(myFavoriteThingsEachCity.call(stLouis, 2, 0, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment