Use destructuring Assignment to Assign Variables from Arrays: how it will swap with just one parameter

Tell us what’s happening:
How will it swap with just one parameter?

Your code so far


let a = 8, b = 6;
(() => {
  "use strict";
  // change code below this line
  [b, a] = [a, b]
  // change code above this line
})();
console.log(a); // should be 6
console.log(b); // should be 8

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays

I’ve edited your post to include your question from the title.

From the challenge:

The variable a is assigned the first value of the array, and b is assigned the second value of the array.

[b, a] = [a, b]
// the same as
var temporaryArray = [a, b];
a = temporaryArray[1];
b = temporaryArray[0];

Same here… still don’t understand what happened there

It isn’t
[b, a] = [a, b]
is
[a, b] = [b, a]