What is happening‽‽‽

What am I supposed to do!!!‽‽‽‽


let a = 8, b = 6;
// Only change code below this line
[,,,,,a,, b] = [1, 2, 3, 4, 5, 6, 7, 8];

console.log(a, b);

Use Destructuring Assignment to Assign Variables from Arrays

If, following the examples, this

[a, b] = [1, 2];

sets a = 1 and b = 2, how do you use the same pattern (with variables) to take

let a = 8, b = 6;

and end with a = 6 and b = 8? And you have to use array destructuring ([...] = [...]) and not

tmp = a;
a = b;
b = tmp;

Thank You So Much!!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.