FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Pairs

10mins

Implement a function pairs(array) that returns an object composed from key-value pairs.

  • array: An array of arrays, where each inner array has exactly two elements: [key, value].

The function should return an object where the first element of each inner array becomes the key, and the second element becomes the value.

Example

pairs([['a', 1], ['b', 2]]); // { a: 1, b: 2 } pairs([['name', 'Alice'], ['age', 25]]); // { name: 'Alice', age: 25 } pairs([]); // {}

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests