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 in sorted form should be unique.
Example:
a=[1,2,3,5,9]b=[4,6,7,8]
function mergeSortdArray(a,b){
for(var i=0;i<b.length;i++){
a.push(b[i]);
}
//console.log(a);
for(i=0;i<a.length;i++)
{
for(j=i+1;j<a.length;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
return a;
}
console.log(mergeSortedArray([1,2,3,5,9],[4,6,7,8]));