-
-
Save codecademydev/cf57152f6b9682b104fd046c9d6070a4 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains 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
let menu = { | |
_course:{ | |
appetizers: ['hello'], | |
mains: [], | |
desserts: [], | |
}, | |
getAppetizers: function(){ | |
}, | |
setAppetizers: function(appetizerIn){ | |
}, | |
getMains: function(){ | |
}, | |
setMains: function(mainIn){ | |
}, | |
getDesserts: function(){ | |
}, | |
setDesserts: function(dessertIn){ | |
}, | |
getCourses: function(){ | |
return { | |
appetizers: | |
this._course.appetizers, | |
} | |
return { | |
mains: | |
this._course.mains, | |
} | |
return { | |
desserts: | |
this._course.desserts, | |
} | |
}, | |
addDishToCourse: function(courseName, dishName, dishPrice){ | |
let dish = { | |
name: dishName, | |
price: dishPrice, | |
} | |
return this._course[courseName].push(dish); | |
}, | |
getRandomDishFromCourse: function(courseName){ | |
let dishes = this._course[courseName]; | |
const randomIndex = Math.floor(Math.random()*dishes.length); | |
}, | |
generateRandomMeal: function() { | |
let appetizer = this.getRandomDishFromCourse('appetizers'); | |
let mains = this.getRandomDishFromCourse('mains'); | |
let desserts = this.getRandomDishFromCourse('desserts'); | |
let totalPrice = appetizer.price + mains.price + desserts.price; | |
return `Your meal is ${appetizer.name},${main.name},${dessert.name}. The price is ${totalPrice}.` | |
} | |
}; | |
menu.addDishToCourse('appetizers', 'Caesar Salad', 4.25); | |
menu.addDishToCourse('appetizers', 'Tomato Salad', 5); | |
menu.addDishToCourse('appetizers', 'Cheese and Bread', 3); | |
let meal = menu.generateRandomMeal(); | |
console.log(meal) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment