Sobes.tech
Junior — Senior

Converting a list of key-value pairs into an object

livecode

Task condition

Given an array of elements, each having properties name and value. It is required to transform this array into an object where each key is taken from the name property, and the corresponding value from the value property.

// Example
var arr = [{ name: 'width', value: 10 }, { name: 'height', value: 20 }];
// Output {width: 10, height: 20}