-
-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curriculum: Need a more robust way to test for destructuring in the Use Destructuring Assignment to Assign Variables from Arrays challenge #38024
Comments
In my opinion, the instructions for this challenge don't seem to line up with the description. The description shows how to destructure things from an array, the instructions ask to "destructure" and swap the values, but the seed code gives nothing to destructure. I feel like the seed code needs to start you off with an array, and the challenge should be to just destructure something from it without swapping values. an easier fix without rewriting might be: |
I don't mind the swapping, since it's a useful trick to know. Giving the user an array to swap seems like a good idea, though. How about: Use destructuring assignment with the array, and let a = 8, b = 6;
const arr = [a, b];
// change code below this line
// change code above this line
console.log(a); // should be 6
console.log(b); // should be 8 as the seed? |
We could also change test like below:- - text: You should use array destructuring to swap a and b.
testString: assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=/g.test(code)); This thing matches any of the methods even This is just if you want to be flexible with the tests as @RandellDawson says or any solutions of @moT01 or @ojeytonwilliams would work . Tell me what you guys think. |
Have I said something wrong. I am open for criticism. |
No, nothing is wrong @ShubhamCanMakeCommit. That sounds similar to my "easier" suggestion. I would be fine fixing it like this. |
Technically this is still destructuring:
I think you explicitly need to point out that a swap should be done in one operation and therefore this should fail:
|
@snigo We could specify that in the instructions. How could we test to make sure it is on one line? |
the discussion here stopped midway, there is any preferred way on the direction of this? |
@snigo Any thoughts on how best to test that it is performed on one line? |
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. |
Per this forum topic, it was discovered our test for detecting destructuring, is not very flexible
Link to challenge
For example, the following should pass as the current challenge is written.
My first thought was to change the instructions to state something like:
While that would deal with the above code being used, it would not deal with something like:
Anyone have any thoughts on how best to change this challenge's instructions and/or test?
The text was updated successfully, but these errors were encountered: