Reputation: 3223
var cols = [
{id: 1, title: 'First Column', tasks:[] },
{id: 2, title: 'Second Column', tasks:[] },
{id: 3, title: 'Third Column', tasks:[] }
];
var tasks = [
{id: 1, title: 'Bla bla project', column: 1},
{id: 2, title: 'Hip Hop project', column: 1}
]
How can i cycle through the tasks variable and push them into the cols array for the matching column id? is this possible without jquery?
Upvotes: 1
Views: 66
Reputation: 25352
Try like this
cols.map(function(col){
col.tasks=tasks.filter(function(task){ return task.column == col.id; });
})
Upvotes: 2