Home > Software design >  How to convert lower case to upper case of array object
How to convert lower case to upper case of array object

Time:10-09

[
  { name: 'Rahul Patel' },
  { name: 'Karan Patel' },
  { name: 'Shubham Tayal' },
  { name: 'rahul patel' },
  { name: 'Prakash shah' }
]

CodePudding user response:

I am not javascript developer but maybe something like this:

 employes.forEach(element => element.name = element.name.toUpperCase());

CodePudding user response:

const employes=[{name:'Rahul Patel'},{name:'Karan Patel'},{name:'Shubham Tayal'},{name:'rahul patel'},{name:'Prakash shah'}]
    
const toUpper = employes.map(o => ({ name: o.name.toUpperCase() }));

console.log(toUpper);

CodePudding user response:

It would be pretty simple. Just use a map method.

let  employees = [{
  name: 'Rahul Patel'
}, {
  name: 'Karan Patel'
}, {
  name: 'Shubham Tayal'
}, {
  name: 'rahul patel'
}, {
  name: 'Prakash shah'
}];

employees.map(e => e.name = e.name.toUpperCase());
console.log(employees);

  • Related