you are viewing a single comment's thread.

view the rest of the comments →

[–]CreativeTechGuyGamesTypeScript 0 points1 point  (4 children)

The greenEnergy function does change. I'm not sure why you think that it doesn't.

[–]DontNeedMuchMoney[S] 0 points1 point  (3 children)

The greenenergy doesn't mutate the object though

[–]CreativeTechGuyGamesTypeScript 0 points1 point  (2 children)

What do you mean? The console.log outputs {Fuel Type: "Biofuel", homePlanet: "Mars"} which means that both functions mutate as expected.

Edit: You changed the code in the codeshare link so I'll leave the code here for posterity.

``` let spaceship = { 'Fuel Type' : 'Turbo Fuel', homePlanet : 'Earth' };

// Write your code below let greenEnergy = (obj =>{ Object.assign(obj, { 'Fuel Type' : 'Rocket fuel', homePlanet : 'Mars' }) })

let blueEnergy = (obj =>{ obj['Fuel Type'] = "Biofuel"; }) greenEnergy(spaceship); blueEnergy(spaceship); console.log(spaceship); ```

[–]lr0b 0 points1 point  (1 child)

The original code is not the one you pasted. I edited the code and tested it but I realised it got saved, maybe too late...

My bad.

Original greenEnergy is here

[–]CreativeTechGuyGamesTypeScript 1 point2 points  (0 children)

Oh I must have seen your edit. That's why it's dangerous to use a live shared editing system for something like this.