Currently diving into the world of JavaScript and exploring destructuring. My goal is to display the following in the console:
"Name: Mike Smith, Father: Harry Smith"
"Name: Tom Jones, Father: Richard Jones"
Encountering an error message stating n is not defined, even though it should be fine? Here's the code snippet I've been working on:
const people = [
{
name: 'Mike Smith',
family: {
mother: 'Jane Smith',
father: 'Harry Smith',
sister: 'Samantha Smith'
},
age: 35
},
{
name: 'Tom Jones',
family: {
mother: 'Norah Jones',
father: 'Richard Jones',
brother: 'Howard Jones'
},
age: 25
}
];
const kalle= people.map(( {name: n, family: {father: f}})=> {
return [n,f]
});
console.log('Name: ' + n + ', Father: ' + f);
// "Name: Mike Smith, Father: Harry Smith"
// "Name: Tom Jones, Father: Richard Jones"