When a pair of values arrives together, destructuring names its parts by position. Try it with coordinates in script.js, then read the Console checkpoints.
Destructuring unpacks array values into variables based on their positions. The next module applies a similar idea to named object properties.
const point = [3, 7];
const [x, y] = point;
console.log(x); // 3
console.log(y); // 7
const [first, , third] = [10, 20, 30];
console.log(first); // 10
console.log(third); // 30
const [head, ...tail] = [1, 2, 3, 4, 5];
console.log(head); // 1
console.log(tail); // [2, 3, 4, 5]
let a = 1, b = 2;
[a, b] = [b, a];
console.log(a, b); // 2 1
const [x = 0, y = 0, z = 0] = [10, 20];
console.log(z); // 0 — default applied
const coords = [40.7128, -74.0060], use array destructuring to extract latitude and longitude.const stops = ["Harbor", "Museum", "Library"], destructure its first and third stops while skipping the middle.swapPair([a, b]) that takes a two-element array and returns it with elements swapped: swapPair([1, 2]) → [2, 1].Harbor to Library | lat: 40.7128 using the destructured values.Array destructuring: const [a, b, c] = myArray;
Skip elements with commas: const [first, , third] = arr;
Use rest: const [head, ...tail] = arr;