score:3

there's two issues here. firstly the braces around the second map() call will be interpreted as a code block, yet it does not return any value so the resulting array will be empty. remove those braces.

secondly, item.column.path needs to be item[column.path] as you're using column.path as the property accessor of item.

here's a working example:

const movies = [{_id:"5b21ca3eeb7f6fbccd471815",title:"terminator",genre:{_id:"5b21ca3eeb7f6fbccd471818",name:"action"},numberinstock:6,dailyrentalrate:2.5,publishdate:"2018-01-03t19:04:28.809z",liked:!0},{_id:"5b21ca3eeb7f6fbccd471816",title:"die hard",genre:{_id:"5b21ca3eeb7f6fbccd471818",name:"action"},numberinstock:5,dailyrentalrate:2.5},{_id:"5b21ca3eeb7f6fbccd471817",title:"get out",genre:{_id:"5b21ca3eeb7f6fbccd471820",name:"thriller"},numberinstock:8,dailyrentalrate:3.5},{_id:"5b21ca3eeb7f6fbccd471819",title:"trip to italy",genre:{_id:"5b21ca3eeb7f6fbccd471814",name:"comedy"},numberinstock:7,dailyrentalrate:3.5},{_id:"5b21ca3eeb7f6fbccd47181a",title:"airplane",genre:{_id:"5b21ca3eeb7f6fbccd471814",name:"comedy"},numberinstock:7,dailyrentalrate:3.5}];
const columns = [{path:"title",label:"title"},{path:"genre",label:"genre"},{path:"numberinstock",label:"stock"},{path:"dailyrentalrate",label:"rate"}];

let output = movies.map(item => columns.map(column => item[column.path]));
console.log(output);


Related Query

More Query from same tag