Skip to content

#294 Destructuring

Adam Kubiś edited this page Oct 28, 2026 · 1 revision

294 Destructuring

Using Destructuring Assignment, your task is to unpack the arrays writeyourcodehere into three variables, first, a variable to ignore all middle values and last.

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/294 Destructuring.js"

Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.

Current implementation and tests

This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.

//Using Destructuring Assignment, your task is to unpack the arrays writeyourcodehere into three variables, first, a variable to ignore all middle values and last.
const [first, , , , , , , last] = [1, 2, 3, 4, 5, 6, 7, 8];
import { assertEquals } from '../testHelper.js';
assertEquals(first, 1)
assertEquals(last, 8)

Clone this wiki locally