Let’s say I have this array of objects:
var array = [
{
"identifier": "A",
},
{
"identifier": "B",
},
{
"identifier": "C",
},
{
"identifier": "D",
},
]
How can I map/reduce this array to get this result:
var array = [
{
"identifier": "A",
},
{
"identifier": "C",
},
{
"identifier": "D",
},
{
"identifier": "B",
},
]
In other words, how can I put “B” at the end of array no matter how large the array is?
array.map((o) => {
if (o.identifier === 'B') {
// do what here?
}
return o;
})