JSFiddle - React, Tailwind, and code Playground
by cmruser
JavaScript
function practice (i){
return i+1;
};
var a = [ -1, 0, 1, 2, 3, 4, 5 ];
var b = [ 0 ];
var c = [ 0 ];
console.log(a);
b = a.forEach(practice);
console.log("=====");
console.log(a);
console.log(b);
c = a.reduce(practice);
console.log("=====");
console.log(a);
console.log(c);
var blocks = [
{
id: 1,
content: [],
map: null
},
{
id: 2,
content: [],
map: 1
},
{
id: 3,
content: [],
map: 1
},
{
id: 4,
content: [],
map: 2
},
{
id: 5,
content: [],
map: null
}
];
var fields = [
{
id: 1,
name: 'field',
map: 2
}
]
// how get new array using map, filter, reduce, find?
var result = [
{
id: 1,
content: [
{
id: 2,
content: [
{
id: 4,
content: [],
map: 2
},
{
id: 1,
name: 'field',
map: 2
}
],
map: 1
},
{
id: 3,
content: [],
map: 1
}
],
map: null
},
{
id: 5,
content: [],
map: null
}
]
var array = blocks.map(block => {}).filter();
{
id: 2,
content: [
],
map: 1
},
{
id: 3,
content: [],
map: 1
}