How do I access my object from my function with Object.assign(target, source)?

Hello,
I am playing around with some code from the course ‘Advanced Objects’.
here is the code :slight_smile:

function whatIsThisCake(Ingredients, Tools, Baking) {
  return {
  Ingredients,
    Tools,
    Baking,
    Cake() {
      if(this.Ingredients === 'magic' && this.Tools === 'batteur' && this.Baking === 'oven') {
        return 'It\'s a magic cake!';
      } else {
        return 'I don\'t want this cake';
      }
    }
}  
};

const myCakeIs = whatIsThisCake('magic', 'batteur', 'oven');
console.log(myCakeIs.Cake()); // return It's a magic Cake!


const newIngredients = {
  moreIngredients : 'Big Powder',
  moreTools : 'Always more tools'
};

const myBigCake = Object.assign(newIngredients, ); /* What am I suppose to name the source as I don't have an object name in the function. What should I do? */
console.log(myBigCake);

So I am blocked because of the source parameter. Any idea?

Hi,
you’ve assigned an instance of the object to ‘myCakeIs’. So why not take that?

Worked! thank you! I thought I tried it haha. Thanks for your help :slight_smile:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.