Can't pass " Use Destructuring Assignment to Assign Variables from Objects "

Can't pass " Use Destructuring Assignment to Assign Variables from Objects "
0

Did come off a little jerky but not much. Doesnt matter though because your guidance helped me pass the challange as well. Thanks snowmonkey.

Thanks for the good comments on the suggestions. We have a lot more knowledge is good.:ta สมัคร UFABET
สมัครเอเย่นต์
แทงบอลออนไลน์

had the same problem, thank you snowmonkey for clearing things up!

1 Like

Thanks for the good comments on the suggestions. We have a lot more knowledge.:ta สมัคร UFABET
สมัครเอเย่นต์
แทงบอลออนไลน์

Im also get problem with this challenge,

Summary
const AVG_TEMPERATURES = {
 today: 77.5,
 tomorrow: 79
};

function getTempOfTmrw(avg) {
 "use strict";
 // change code below this line
const { tomorrow: tempOfTomorrow } = avg; 
 // change code above this line
 return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

In console i see

Summary

// running tests
destructuring with reassignment was used
// tests completed

Have you changed variables or function names? If you see a “don’t change code below/above this line” you have to respect that to pass the challenge

Always glad to help. Best of luck, and you have no idea how happy I am to see so many folks searching the forum rather than simply asking the same question over again.

:smiley:

Okay, so you changed the parameter name from avgTemperatures to avg. Yes? Don’t.

The code you’re given contains two lines:

...
 // change code below this line
...
 // change code above this line
...

In changing that variable name, you went outside the lines you were expressly told to edit. There is a test hook that is looking for avgTemperatures, and you’ve broken it.

jes. im so stupid xD first time i used
const { tomorrow: tempOfTomorrow } = AVG_TEMPERATURES;
Next time code from my prev msg. and now i see what’s i did wrong. ty snowmonkey

I think I get what you are saying about using avgTemperatures rather than the global variable name AVG_TEMPERATURES in the body of the getTempOfTmrw function.

BUT… we do refer directly to that global variable’s properties (today, tomorrow) as we write the getTempOfTmrw function.

How is it OK to “know” that those properties exist (and use those property names in the function), but not to “know” and use the global object name’s?

1 Like

You function should be written to know in advance what valid properties can exist on the object that you would pass to the function. You want to reference the function’s variable, because you may want to pass multiple objects by iterating through an array of 1,000,000 objects of the same type. There would be no global variable per say, but you “know” the blueprint of the objects coming in and plan for your function to destructure them appropriately.

1 Like

There is another issue for freeCodeCamp. It’s been a terrific resource for me, but when I click the “Get a hint” button it calls up an almost totally unrelated page: https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/.

The page talks about string.length, which has nothing to do with this challenge.

1 Like

Yes, some of the Guide articles need to be corrected. If you would be interested in contributing, you can read How to work on Guide articles and help us make the Guide better.

1 Like