Merging array entries referenced by indexes in another array
If you index the answers to the index of the questions you can do this:



let r_arr = {
            0: true,
            3: false
};
let q_arr = [
            { q: 'some question one', o: [true, false] },
            { q: 'some question two', o: [true, false] },
            { q: 'some question three', o: [true, false] },
            { q: 'some question four', o: [true, false] }
        ];

var a = q_arr.map((q, i) =&gt; ({'q': q.q, 'o': i in r_arr ? r_arr[i]  : 'na'}) )
console.log(a)




You'll need to account for the fact that js arrays are zero indexed.