Skip to content

Instantly share code, notes, and snippets.

@Dangeranger
Created April 20, 2021 22:49
Show Gist options
  • Save Dangeranger/5c58d2b79d4c832744b686c816daafde to your computer and use it in GitHub Desktop.
Save Dangeranger/5c58d2b79d4c832744b686c816daafde to your computer and use it in GitHub Desktop.
Some starter code for the cakeMaker lab. Please finish me.
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