Destructuring Assignment of two variables doesn't work

Destructuring Assignment of two variables doesn't work
0

#1

Tell us what’s happening:

I set the destructuring assignment but it doesn’t return what expected.
What goes wrong? I assigned to a the value of b and to b the value of a.

Your code so far


let a = 8, b = 6;
(() => {
  "use strict";
  // change code below this line
  const [a, b] = [b, a];
  
  // 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 6.3; 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


#2

I resolved. I had to remove const because the variables was already assigned before.