From f3fd951446fa6fb7b53616fa674deaa7dbf3e0b9 Mon Sep 17 00:00:00 2001 From: geeseyj Date: Mon, 25 Feb 2019 12:57:50 -0500 Subject: [PATCH] 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 --- ...gnment-to-assign-variables-from-arrays.english.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 15077042c4..38974f98d9 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 ```