In this program merged two array and then sorted using temp.but this not correct method.because two array are sorted ,so method should be unique i.e. merging of two sorted i
function mergeSortedArray(a, b) { var arr = a.concat(b).sort(function(a, b) { return a - b; }); return arr; } console.log(mergeSortedArray(a, b));