Why does the second destructuring swap here fail?
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a, b);
let x = 1
let y = 2
[x, y] = [y, x]
console.log(x, y)
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a, b);
let x = 1
let y = 2
[x, y] = [y, x]
console.log(x, y)
Work out every line it logs, in order. Then check.
Checking your sign-in…
New here? Ask where to start, what each guide covers, or how the interactive lessons work. Tuto answers and links you to the right page.
Your first 3 answers need no account. for free to keep asking.