Q:

Write a JavaScript program to create a new object from the specified object, where all the keys are in lowercase

0

Write a JavaScript program to create a new object from the specified object, where all the keys are in lowercase.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const lowercaseKeys = obj =>
  Object.keys(obj).reduce((acc, key) => {
    acc[key.toLowerCase()] = obj[key];
    return acc;
  }, {});
const myObj = { Name: 'Adam', sUrnAME: 'Smith' };
const myObjLower = lowercaseKeys(myObj);
console.log(myObjLower);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now