I would like to copy an array of objects in a nested object with new property. How can I use es6 to achieve something like this
I would like to copy:
['cat', 'Dog', 'monkey'] into
[{"text":"cat"},{"text":"Dog","extraClasses":["ti-extra"]}, {"text":"monkey"}]
>Solution :
Maybe function like this where getClasses function returns classes array.
['cat', 'Dog', 'monkey'].map((item) => {
return { text: item, extraClasses: getClasses() };
});