Need help figuring this out

I can’t seem to get it right. I console logged my code and it was the right value but it kept saying “You should use array destructuring to swap a and b.” what did it mean by that and why is it wrong even if a swapped the values correctly?

Your code so far

let [b, a] = [8, 6]
console.log(a, b)
// Only change code below this line

Your browser information:

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

Challenge: Use Destructuring Assignment to Assign Variables from Arrays

Link to the challenge:

You used hard coded values, but your solution should work no matter what values you initialize a and b to.


This is an example of array destructuring.
You’re on the right track with let [b, a] but we have to fix a couple of things.

  • You can’t use let - a and b are already declared by the code.
  • You’re assigning the values 8 and 6, but the challenge wants you to assign the values of a and b to b and a.

thanks, I was having a hard time figuring it out