Challenge use-destructuring-assignment-with-objects has an issue.
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:51.0) Gecko/20100101 Firefox/51.0
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
In description it says:
"Consider the following ES5 code:"
const voxel = {x: 3.6, y: 7.4, z: 6.54 };
const x = voxel.x; // x = 3.6
const y = voxel.y; // y = 7.4
const z = voxel.z; // z = 6.54
"const" is ES6, should be "var"?
Also: is below code correct? Are there "a", "y", "z" on purpose, maybe to show that you can use xyz and abc?
const { x : a, y : b, z : c } = voxel // a = 3.6, y = 7.4, z = 6.54
edit: I clicked "Run tests" to see some errors descriptions, but instead of errors I got confirmation of solved challenge (and all tests passed even though I didn't change anything in code yet).
Thanks for reporting this issue! This could definitely be improved.
Let's start with your question:
Also: is below code correct? Are there "a", "y", "z" on purpose, maybe to show that you can use xyz and abc?
The description of this example is correct, but as you noticed, there's a problem with the comment that represents the output. This is what happens when running this example in the browser console:
var
instead of const
challengeSeed
code. This makes the linter complain.As you reported this, would you like to make an open source contribution with the fix? Me and other contributors would be happy to guide you through the process! :smile:
Good luck and happy coding! :smile:
I can try. :) Could you also take a look at my "edit" at the end of first post - I highly doubt I can fix that... ;)
edit: I looked at guidelines and as it needs node I'll have to leave it for someone else - I'm on borrowed laptop now. ;)
@gogolab The ES6 challenges currently don't have any working tests - there's a problem when we transpile the code from ES6 to ES5 (so that it actually can run in browsers).
That's unfortunate. Will you be able to fix this in the next week? If so, I think we can assign this to you even if you can't fix it right away :blush:
@Greenheart
Oh ok. :)
And yes - in few days I'll be back in my place and could try to fix this issue. :)
@gogolab Great, reach out to us if you need anything more than what's in the comments above :blush:
@Greenheart
there's a problem when we transpile the code from ES6 to ES5 (so that it actually can run in browsers).
Do you need assistance in setting up a webpack config file? I can probably lend a hand here if thats the case.
@Ethan-Arrowood thanks for offering to help.
@BerkeleyTrue what's the status of ES6 transpilation?
Hi, can't seem to find what's wrong with my solution after carefully checking the example given in the lesson [(https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/)].
`const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const tempOfTomorrow = undefined; // change this line
// change code above this line
return tempOfTomorrow;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79`
Changed the 'change this line' with this code :
const {today: x, tomorrow: tempOfTomorrow} = avgTemperatures;
The solution returned the correct value of 79 but 'destructuring with reassignment was used' objective was not met.
const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};
function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const {tomorrow: tempOfTomorrow } = avgTemperatures;
// change code above this line
return tempOfTomorrow;
}
console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
This bug has cost a lot of time to me
Most helpful comment
@Ethan-Arrowood thanks for offering to help.
@BerkeleyTrue what's the status of ES6 transpilation?