Use Destructuring Assignment to Assign Variables from Arrays_Something was wrong

Use Destructuring Assignment to Assign Variables from Arrays_Something was wrong
0

#1

I could do it but i could not understand. I changed numbers in first line and add seventh line add destructuring. Everything is correct or not ? Please someone help

  let[a, b] = [6,8];

Your code so far


let a = 6, b = 8;
(() => {
  "use strict";
  // change code below this line
  let[a, b] = [6,8];
  // 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 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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

There are two problems.

First, by using the keyword let inside your function you are creating a new local variable with the same names as the global. When the function ends, those variables are discarded.
Second, you are supposed to swap values, not set them to 6, 8. ^^