The Partitioner

Medium+20 XP

Mission Briefing

The supply pod contains a massive array of resources, but the engineers strictly need the very first two items immediately! You must extract them using the cleanest code possible.

The Concept: Destructuring

Destructuring is an incredibly powerful ES6+ syntax that allows you to instantly unpack values from arrays (or properties from objects) into distinct variables! Example: const [first, second] = [10, 20];

The Objective

Your function receives an array of numbers nums.

  1. Unpack the first two elements of nums into variables a and b using destructuring syntax.
  2. Return their accumulated sum.

01EXAMPLE 1

Inputnums = [10, 20, 30]
Output30

Constraints

  • Use array destructuring [a, b] = nums.
CoreES6+
JavaScript
Loading...
3 Hidden

Input Arguments

nums[10,20,30]

Expected Output

30

Click RUN to test your solution