Ramda add new property to every element in object

js:


var data = [

 {id: 10, name: 'user-10'},

 {id: 15, name: 'w-user-15'},

 {id: 20, name: 'user-20'},

];



var output = R.pipe(

  R.map(el => {

    return {

      ...el,

      'name_up': el.name.toUpperCase()

    };

  }),

)(data);



alert( JSON.stringify(output) );

Result:

Leave a Comment