I was wondering if someone could explain to me how to merge two arrays so that one is not simply appended to the other, but they need to be merged into one sorted array. I could simply append the two arrays and then sort the result, but that would be too easy. Instead I need to have my javascript look over each element of both arrays to see which number is smaller to merge into one sorted array. I need to be able to understand how and why it works if possible.
For example:
arr1 = [1,2,7,10];
arr2 = [3,4,9,19];
//needs to merge into one array appearing as [1,2,3,4,7,9,10,19];
Any quick explanation on how to do this would be greatly appreciated. Have a wonderful holiday weekend everyone and I look forward to talking with someone soon.