Pass By Reference Help

Could anyone please help me with this code

Link to the lesson:

Code: `let spaceship = {
‘Fuel Type’ : ‘Turbo Fuel’,
homePlanet : ‘Earth’

// Write your code below
let greenEnergy();
‘Fuel Type’ : ‘avacado oil’;`

Please anyone answer as soon as possible

I guess you’re having trouble with the first step, so to create a function there are two options:
a) The “classic” one:

function name(Args) {

b) Arrow function

const name = (Args) => {

I usually use the arrow functions. In your case we need to change one property of the spaceship oblect, so we need a function that takes an object as parameter and change the ‘Fuel Type’ property like this:

function greenEnergy(obj) {
obj['Fuel Type'] = 'avocado oil';

or if we use the arrow function it look like this:

const greenEnergy = (obj) => {
obj['Fuel Type'] = 'avocado oil';

Than we hav another option, because with the arrow function when we have only one parameter we can avoid using the braces around the parameters, like this:

const greenEnergy = obj => {
obj['Fuel Type] = 'avocado oil';

Than you just call the function and pass the object as a parameter:


Let me know if this was your problem

1 Like

yes this was the problem, thank you very much