domenic / count-to-6

An intro to some ES6 features via a set of self-guided workshops.
Other
326 stars 76 forks source link

Destructuring asignment misleading #37

Closed mn113 closed 7 years ago

mn113 commented 7 years ago

I've just spent quite a bit of time on problem 5 because there is no information in the instructions (or on the web for that matter) about how to do a destructured assignment into an object.

If you google ES6 destructuring, all the examples show assignments to simple variables rather than object properties.

The given solution achieves this using [, result.username, result.email] = args; which works, but can be the source of many frustrations because it gives an unhelpful syntax error if preceded with the let keyword.

All the examples given in this problem are misleading because they all use let: let [foo, , baz] = numbers; let {width:x, depth} = box; So the learner is not aware that the keyword must be left off if wishing to assign to an object's properties.

I would add another example so that the learner has all the pieces of the puzzle in front of them before they embark on solving it.

zbicin commented 7 years ago

Thanks for your feedback, I will surely have a look at this excercise.