Sobes.tech
Junior — Senior

Transforming a list of strings into an array of objects with name and id fields

livecode

Task condition

It is necessary to convert an array of strings into an array of objects, where each object contains a name field equal to the original string, and an id field — its index in the array.

// ['foo', 'bar'] → [{ name: 'foo', id: 0 }, { name: 'bar', id: 1 }]