freeCodeCamp Challenge Guide: Use Destructuring Assignment to Assign Variables from Arrays

Use Destructuring Assignment to Assign Variables from Arrays


Hints

Hint # 1

We have to take some precaution in this case.

  1. Do not try to re-declare a or b while destructuring as they are already declared in the first let statement.

Solutions

Solution 1 (Click to Show/Hide)
let a = 8, b = 6;
[a, b] = [b, a];
42 Likes