ES6 - Use Destructuring Assignment to Pass an Object as a Function's Parameters

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

const stats = {
  max: 56.78,
  standard_deviation: 4.34,
  median: 34.54,
  mode: 23.87,
  min: -0.75,
  average: 35.85
};

// Only change code below this line

const half = () => stats.max + stats.min / 2.0; 
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.731 YaBrowser/23.11.1.731 Yowser/2.5 Safari/537.36

Challenge Information:

ES6 - Use Destructuring Assignment to Pass an Object as a Function’s Parameters

Has anyone solved this problem, why is it so complicated? Of course, I understand that no one here can explain why this nonsense is needed, but which newbie can do it himself?

Yes, newbies have solved this before. Yes, people can do this on their own or with help.

Do you have a question about this Challenge related to how you’re stuck?

I got that you’re frustrated, but this forum is for getting help solving coding problems.

спользуйте деструктирующее присваивание внутри аргумента функции half для отправки только max и min внутри функции.
I rarely understand instructions, as the task is described here, I don’t understand anything here

const half = () => {
 const arr = stats.max + stats.min / 2.0; 
 return arr
}

I understood it like this

I really think your translation tool isn’t very good.

The instructions say

Use destructuring assignment within the argument to the function half to send only max and min inside the function.

And this is the example

const profileUpdate = ({ name, age, nationality, location }) => {

}

When profileData is passed to the above function, the values are destructured from the function parameter for use within the function.

I don’t see anything that looks like that in your arguments list. The arguments list is that part of the function that is in the ()s.

const half = ({max, min}) => stats.max + stats.min / 2.0;

Then it became clear to me that this simply does not work.

What ‘simply does not work’?

Deleting the ()s around the numerator changes the calculations here.

const half = ({max, min}) => (stats.max + stats.min) / 2.0;

error warnings are issued Destructured parameter should be used

Theses are now your function arguments

So you need to use them inside of the function body.

const half = ({max, min}) => {
(stats.max + stats.min) / 2.0;  
return max, min
}

it doesn’t work and I still don’t understand how it could be otherwise from these lessons.

It doesn’t work because you are using stats which is not a function argument. You’re ignoring the function arguments and just sticking them in at the end. You have to use them in place of where the old argument was used.

Yes, this is impossible to understand, then what is the connection with the object if you remove the object?

const half = ({max, min}) => {
(max + min) / 2.0;  

}

this doesn’t work at all, it gives an error half(stats) should be 28.015

If it’s impossible for you to understand, then you should try a different curriculum. Not every curriculum works perfectly for every learner.

const profileUpdate = (profileData) => {
  const { name, age, nationality, location } = profileData;

}
const profileUpdate = ({ name, age, nationality, location }) => {

}

These codes do the same thing, so you use name, age, nationality, location the same way as you would with destructuring inside of the function body. Do you know what destructuring does?

What is all of your current code?

You aren’t returning anything from this function.

here I completely agree, but where should I study there, of course everything is clear to me, but I don’t understand anything here

changes variables or values

I don’t know where might work better for you, but this forum isn’t the place to be insulting towards people who are writing this curriculum for free.

I definitely get feeling frustrated, but we really are trying to make these lessons work for as many people as possible. Learning code is really, really hard to do. It’s totally normal to struggle and feel frustrated.

I do really think that your translation app isn’t doing a very good job accurately translating the meaning of the text.

Like here. I don’t know what you mean at all. Bad translation.

my code somehow finds a statistics object, or rather a function, with two arguments in the values, then in the body of the function it adds min max and divides by 2, after which it needs to return the result