I have an array of cat objects and I have to use the map function to change the "readyForHome" property from a string 'Yes' 'No' to be a boolean value true or false. It will be a part of a function that does various other things to the array.
I'm pretty new to higher order functions and everything I've read on here doesn't seem to work for me. Does anyone have an idea as to how they would approach this?
var cats = [
{ id: '1', name: 'rupert', readyForHome: 'No', age: 12, personality: ['friendly', 'lazy', 'loving']},
{ id: '2', name: 'mrs fluffy', readyForHome: 'Yes', age: 2, personality: ['affectionate', 'playful', 'shy']},
{ id: '3', name: 'tabitha', readyForHome: 'Yes', age: 4, personality: ['aggressive', 'independent']},
{ id: '4', name: 'lily', readyForHome: 'No', age: 8, personality: ['friendly', 'playful', 'mischievous']},
{ id: '5', name: 'stripe', readyForHome: 'Yes', age: 1, personality: ['haughty', 'independent']},
{ id: '6', name: 'bob', readyForHome: 'Yes', age: 1, personality: ['aggressive', 'antisocial', 'nervous']},
{ id: '7', name: 'jean claude cat damme', readyForHome: 'Yes', age: 11, personality: ['sleepy', 'shy', 'loving']},
{ id: '8', name: 'tilly', readyForHome: 'Yes', age: 4, personality: ['playful', 'social', 'attention-seeking']},
{ id: '9', name: 'milo', readyForHome: 'No', age: 7, personality: ['mischievous', 'friendly']},
{ id: '10', name: 'mr claws', readyForHome: 'Yes', age: 13, personality: ['affectionate', 'shy', 'nervous']},
{ id: '11', name: 'robert zimmercat', readyForHome: 'Yes', age: 3, personality: ['folksy', 'prolific', 'neurotic']}
];
if(row.readyForHome.toUpperCase() == "YES") row.readyForHome=true; else row.readyForHome = false;