Destructuring Assignment to Assign Variables from Arrays - Const or not to Const

I know what the answer is now but, can anyone tell me why this does not work with:

const [b, a] = [a, b]

The example freeCodeCamp gives uses const and then it doesn’t work in the challenge. Very confusing.

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

Found the answer on another question.

You shouldn’t use the const keyword in this case, because you want to manipulate the existing a and b variables, not make new ones.