diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.english.md index 15077042c41..38974f98d9e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.english.md @@ -30,7 +30,7 @@ tests: - text: Value of b should be 8, after swapping. testString: assert(b === 8, 'Value of b 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
```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 ```