# 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;
``````

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.

12 Likes

The current solution passes for me:

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))
``````
1 Like

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

1 Like

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.

4 Likes

the tests say they call `half(stats)`

4 Likes

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.

2 Likes

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.

1 Like

@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.

2 Likes

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.

2 Likes

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.

1 Like

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

thanks for the patient feedback!

2 Likes

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

1 Like

As a learner, I would like to add my own experiences with the deconstruction problem: It was the first and only challenge I did not solve myself and needed help. I will not claim that I have solved it with the function call `console.log(half(stats));` but this line would have been helpful in retrospect.

Even if I do not have much knowledge in programming, I do have some adult education experience. I always tried to follow two maxims:

1. Provide a learning environment that comes as close as possible to reality.
2. Whenever possible, make all hidden assumptions transparent.

In my opinion, not including the functional call violates both maxims.

BTW: I found the defense for not including this line strange because I am missing an argument why NOT including this line.

2 Likes

all the challenges have been uniformed to not include function calls in the editor, and as less as possible of other stuff, probably this one like others could also not include the object in the editor but in the description - learners tend to focus too much on global objects instead on having the function being able to do everything, and rely instead on the function parameters. It’s a thing in progress.

I admit, the previous version of the challenge did had that… I think it was my first question on the fourm, or around there - how are the function and the object connected?
I think it’s just really confusing, at a point in which you are starting to familiarise with functions and all the other ES6 stuff, and boom, destructuring, which kind of fry your brain even more

1 Like

Agreed. Having the learner make the leap from seeing that the function they wrote working for the global object and single function call they see in the editor to having the learner understand that functions are reusable entities that do not rely upon their inputs existing on the same screen at the same time seems to be a big stumbling block for some. In real production code, you often have function calls in separate files from the function definition, so learners need to eventually understand that a function can exist and be correct without being called in the same file.

Issues understanding scope and independence of function calls seems to especially come out of the recursion lessons all the time. The abstraction that a function is a separate logical entity and each function call is a separate entity is hard for some people to get used to.

1 Like

I see. This was helpful for me and countered my first maxim as it is obviously a reality that “a function can exist and be correct without being called in the same file.” I didn’t think about that.

But still: Is it pedagogically advisable to explain/teach a new and difficult to understand feature embedded into another complexity? The lesson aims to understand “Destructuring Assignment to Pass an Object as a Function’s Parameters” and not to “understand that a function can exist and be correct without being called in the same file.”

I agree that it is useful and important for raising the level of proficiency to combine different taught concepts into challenges. But after a new taught concept is studied on its own and understood.

2 Likes

Maybe? Somehow we have students this deep into the curriculum who are not understanding that functions exist independent from what similar global variables exist or if the function being called. That is a concept that should be understood by now. This should not be a new idea at this point. And by this point the learner should know how to add function calls and console logs to interact with their function.

What’s the best way to set up this lesson and the entire curriculum? I don’t know. But I’m confused at students not knowing how to add log statements and experiment with the code this far along.

Luckily, we do have the forum to answer any questions that come up. Learning how to ask questions is a big step is becoming a programmer.

2 Likes

I believe I understand our different assessments of the problem. I do not have your broader perspective and experiences with other students. I just wanted to contribute ideas and thoughts about the educational structure of this one challenge.

3 Likes

Yeah, different ideas and perspectives are definitely helpful. You’ve added more information to a problem I don’t yet know how to solve, which is great.

1 Like

Thanks! it makes it easier to understand!

1 Like