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 fullpull/28925/merge
parent
35b3495be1
commit
f3fd951446
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue