Created
April 20, 2021 22:49
-
-
Save Dangeranger/5c58d2b79d4c832744b686c816daafde to your computer and use it in GitHub Desktop.
Some starter code for the cakeMaker lab. Please finish me.
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
let cakesToMake = [ | |
{ flavor: "Chocolate", icing: "Peanut Butter", decoration: "Sprinkles" }, | |
{ flavor: "Vanilla", icing: "Lime", decoration: "Coconut" }, | |
{ flavor: "Strawberry", icing: "Vanilla", decoration: "Fruit" }, | |
]; | |
let cakeList = [ | |
["Chocolate", "Peanut Butter", "Sprinkles"], | |
["Vanilla", "Lime", "Coconut"], | |
["Strawberry", "Vanilla", "Fruit"], | |
]; | |
class Cake { | |
static makeTheCakesFromObjects(cakesToMake) { | |
function makeTheCake(cake) { | |
return new Cake(cake.flavor, cake.icing, cake.decoration); | |
} | |
return cakesToMake.map(makeTheCake); | |
} | |
static makeTheCakesFromList(cakesToMake) { | |
/* | |
PLEASE FINISH ME | |
Using the cakeList | |
*/ | |
} | |
constructor(flavor, icing, decoration) { | |
this.flavor = flavor; | |
this.icing = icing; | |
this.decoration = decoration; | |
} | |
describe() { | |
console.log( | |
`Is is a ${this.flavor} cake, with ${this.icing} frosting, and ${this.decoration}` | |
); | |
} | |
} | |
let manyCakes = Cake.makeTheCakesFromObjects(cakesToMake); | |
console.log({ manyCakes }); | |
manyCakes.forEach(function(cake){ console.log(cake.describe()) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment