Tell us what’s happening:
I have solved this challenge after some Read-Search-Ask but what I don’t understand is why the destructuring assignment works in this case since it is supposed to work only with Arrays? And a and b are not elements of an Array, so how come this assignment works?
Your code so far
SPOILER ALERT: solution below
let a = 8, b = 6; // Only change code below this line [a, b] = [b, a];
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36.
Challenge: Use Destructuring Assignment to Assign Variables from Arrays
Link to the challenge: