curriculum: Need a more robust way to test for destructuring in the Use Destructuring Assignment to Assign Variables from Arrays challenge
See original GitHub issuePer this forum topic, it was discovered our test for detecting destructuring, is not very flexible
For example, the following should pass as the current challenge is written.
let a = 8, b = 6;
// change code below this line
let arr = [a, b];
[b, a] = arr;
// change code above this line
console.log(a); // should be 6
console.log(b); // should be 8
My first thought was to change the instructions to state something like:
Use destructuring assignment to swap the values of a and b so that a receives the value stored in b, and b receives the value stored in a. Do not create any additional variables to solve this challenge.
While that would deal with the above code being used, it would not deal with something like:
let a = 8, b = 6;
// change code below this line
[b, a] = Array(a,b); // or [b, a] = [a].concat(b);
// change code above this line
console.log(a); // should be 6
console.log(b); // should be 8
Anyone have any thoughts on how best to change this challenge’s instructions and/or test?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Use Destructuring Assignment to Assign Variables from Arrays ...
In this JavaScript ES6 tutorial we use destructuring assignment to assign variables from arrays. This is one part of a multi-part series ...
Read more >ES6 - Use Destructuring Assignment to Assign Variables from ...
ES6 - Use Destructuring Assignment to Assign Variables from Arrays - Free Code Camp · How to Use the Rest Parameter with Function...
Read more >How to Use the Destructuring Assignment to Assign Variables ...
By watching this video, you will learn how to use the destructuring assignment to assign variables from array elements.
Read more >Why is this useful? : destructuring assignment to assign ...
I've completed the challenge correctly, but I feel like the test example is more confusing than the description.
Read more >Functions - Julia Documentation
Function arguments themselves act as new variable bindings (new locations that can refer to values), but the values they refer to are identical...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, nothing is wrong @ShubhamCanMakeCommit. That sounds similar to my “easier” suggestion. I would be fine fixing it like this.
Thank you for reporting this issue.
This is a standard message notifying you that the issue has become stale, so we are going to close it.
If you think we’re wrong in closing this issue, please request for it to be reopened. Thank you and happy coding.