I'm looping through object sliced where I want to extract properties name into theRest variable. With code below I get an error Cannot read property name of undefined
My object sliced gives me an array: [{name: 'Bart'},{name: 'Lisa'},{name: 'Maggie'}]
const theRest = sliced.map((item, i) => {
item[i].name;
})
Sorry for variables naming if tht's confusing but I hope you get an idea.
let theRest =mapinstead offorEach? Also, it’s justitem, notitem[i].item.nameand don't forget to return the value from your function