Junior
Merging two arrays
livecode
Task condition
There are two services that return a list of active credit applications sorted by ascending id, with id being unique across both services. It is necessary to obtain a list of the last k credit applications:
const getDecisions1 = [
{id: 1, result: 'approved'},
{id: 3, result: 'waiting'},
{id: 15, result: 'approved'},
{id: 20, result: 'approved'},
{id: 26, result: 'waiting'},
{id: 30, result: 'approved'},
];
const getDecisions2 = [
{id: 2, result: 'approved'},
{id: 4, result: 'waiting'},
{id: 14, result: 'approved'},
{id: 16, result: 'approved'},
{id: 23, result: 'waiting'},
{id: 32, result: 'approved'},
];
const getLastDecision = (decision1, decision2, k) => {
}
getLastDecision(getDecisions1, getDecisions2, 5) //
//[
// {id: 32, result: 'approved'},
// {id: 30, result: 'approved'},
// {id: 26, result: 'waiting'},
// {id: 23, result: 'waiting'},
// {id: 20, result: 'approved'}
//]