Javascript: From array to object

JS: Objects
Last update: 14 Sep 08:12
0
Students

fromPairs.js

Implement and export as default a function that takes an array of array-pairs and returns an object derived from those pairs.

Tips

  • If same keys are found when constructing an object, take the value from the last array-pair:
fromPairs([['cat', 5], ['dog', 6], ['cat', 11]])
// { 'cat': 11, 'dog': 6 }

Examples

fromPairs([['fred', 30], ['barney', 40]]);
// { 'fred': 30, 'barney': 40 }

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests