Deconstruction solution incomplete

the solution for this deconstruction problem is incomplete! it requires another step for the instruction to be useable. the student must understand that the current ‘solution’ doesn’t work in a real-world use scenario because THERE IS NO WAY FOR half TO KNOW THAT stats IS BEING PASSED INTO IT!!

a simple, more complete, solution to this would be something like this:

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

const half = ({max,min}) => (max + min) / 2.0;
console.log(half(stats));  // <---------  add this

i’ve come across several such ‘solutions’ and finally had to say something. the novice student may use this as reference and may not connect the necessary dots to get this to work. which means they’re frustrated and that’s not useful when learning.

plus it’s just NOT COMPLETE.

ahem. please fix.

1 Like

The current solution passes for me:
image

When I pass in an object with a max and a min, the function works just fine in “real world” code.

const someObj = {
  max: 56.78,
  random_thingy: 4.34,
  min: -0.75,
};

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

console.log(half(someObj))

because you knew you had to ADD the console.log function. if you leave that out, the test still passes. which it SHOULDN’T.

It should pass. The instructions state

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

Calling the function is not part of the instructions. The console.log has absolutely nothing to do with rewriting the function half to use destructuring.

the tests say they call half(stats)

1 Like

my point is that call should be in the code. the whole reason i am actually doing this post is because a colleague got stumped on this question and asked me about it. so as a learning tool, this should have the call in the code. which, AFAIK, is what this site is all about. plus it’s a small tweak that adds a lot of clarity for noobs.

said my piece. i leave it to the admins.

The function call is in the test. The user is supposed to modify the function to have the appropriate behavior when the function is called.

Honestly, if a user is that far into the ES6 section and does not understand the difference between a function and a function call or does not know how to experiment with a function to see what it does, they probably are moving too fast and are not ready for the lesson they are on.

@JeremyLT that’s a good point. i’ll mention it to my colleague. he’s a pretty linear thinker (a touch on the spectrum methinks) and is trying hard to get up to speed on our projects. i’ll also have a word with our training officer. maybe she can help him pump the brakes a bit.

Welcome, Iansebryk.

Thank you, for taking the time to provide feedback about your experience with this lesson. It is useful to have, and perhaps there is conversation to be had about improving either, as you have mentioned, this lesson, or the lessons prior so that this one is not out-of-the-blue.

I will mention this: The curriculum is under an overhaul (almost always has been), and the current lessons and their structure are likely to become legacy (obsolete) with version 7 of the curriculum. There is no set date on this, but it is something to keep in mind. Read more here: Help us build Version 7.0 of the freeCodeCamp curriculum - Contributors - The freeCodeCamp Forum

If you want, I recommend heading over to the mentioned resources to help contribute to what is still available.

Thanks again.

1 Like

I can definitely understand the impulse to rush and get up to speed on a project rapidly.

This section might be more useful to start with in that sort of situation. I’m still not quite sure why it’s not higher up in the list of sections.

i agree. debugging is something so few learn properly. it should be higher on the list, introduced earlier.

thanks for the patient feedback! :smiley:

1 Like

@Sky020 you bet! thank you. i hope my underlying desire to improve content is evident. i’m not looking to troll but improve. :slight_smile: