I have some jumbled string values in an object and I would like to replace them all with versions that are all lowercase.

Also, I only need to know the total number of books. So i am deleting booksInLibrary and booksNotInLibrary keys. I want to add a key of totalBooks which is equal to the sum of the values that were under booksInLibrary and booksNotInLibrary.

const newHouse = {
hasEggCupHolder: true
diningTable: 'It's an extenDer'
booksInLibrary: 3
booksNotInLibrary: 2
toilet: 'BuCk RodGerS'
};

function moveHouse(newHouse) {
newHouse.totalBooks = newHouse.booksInLibrary + newHouse.booksNotInLibrary;
Object.entries(newHouse).forEach(([k]) => [k.toLowerCase()]);
delete newHouse.booksNotInLibrary
delete newHouse.booksInLibrary

return newHouse;
}
0

There are 0 best solutions below