SHARE
TWEET

Untitled

a guest Oct 10th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let menu = {
  2.     _courses: {
  3.       appetizers: [],
  4.       mains: [],
  5.       desserts: []
  6.     },
  7.   // get currentAppetizers() {
  8.   // },
  9.   // set newAppetizers(appetizerIn) {
  10.   // },
  11.   // get currentMains() {
  12.  
  13.   // },
  14.   // set newMains(mainsIn) {
  15.   // },
  16.   // get currentDesserts() {
  17.  
  18.   // },
  19.   // set newDesserts(dessertsIn) {
  20.   // },
  21.   // get _courses() {
  22.   // },
  23.   addDishToCourse (courseName, dishName, dishPrice) {
  24.     let upadatedMenu = this._courses;
  25.     const dish = {
  26.       name: dishName,
  27.       price: dishPrice
  28.     };
  29.     return upadatedMenu[courseName].push(dish);
  30.   },
  31.   getRandomDishFromCourse(courseName) {
  32.     const dishes = this._courses[courseName];
  33.     const randomIndex = Math.floor(Math.random()*dishes.length);
  34.     return dishes[randomIndex];
  35.   },
  36.  
  37.   generateRandomMeal() {
  38.     const appetizer = getRandomDishFromCourse('appetizers');
  39.     const mains = getRandomDishFromCourse('mains');
  40.     const desserts = getRandomDishFromCourse('desserts');
  41.     const totalPrice = appetizer.price + mains.price + desserts.price;
  42.  
  43.     return `Your meal is ${appetizer.name}, ${mains.name}, {desserts.name}. The price is ${totalPrice}`
  44.   }
  45. }
  46. menu.addDishToCourse('mains', 'schabowy', 12);
  47. menu.addDishToCourse('desserts', 'koktail', 9);
  48. menu.addDishToCourse('appetizers', 'zupa', 6);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top