fix(coding): uncomment destructuring test and add solution (#18909)

* fix(coding): uncomment destructuring test and add solution

the test that ensured destructuring was being used had been left commented out and there was no solution offered. I uncommented the test and verified it worked as well as added the solution.

* fix: corrected partial solution to full
pull/28925/merge
geeseyj 2019-02-25 12:57:50 -05:00 committed by Aditya
parent 35b3495be1
commit f3fd951446
1 changed files with 10 additions and 2 deletions

View File

@ -30,7 +30,7 @@ tests:
- text: Value of <code>b</code> should be 8, after swapping.
testString: assert(b === 8, 'Value of <code>b</code> should be 8, after swapping.');
- text: Use array destructuring to swap a and b.
testString: // assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code), 'Use array destructuring to swap a and b.');
testString: 'assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code), "Use array destructuring to swap a and b.");'
```
@ -63,6 +63,14 @@ console.log(b); // should be 8
<section id='solution'>
```js
// solution required
let a = 8, b = 6;
(() => {
"use strict";
// change code below this line
[a, b] = [b, a];
// change code above this line
})();
console.log(a); // should be 6
console.log(b); // should be 8
```
</section>