Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Merge Two Arrays
//Title of this code //V8 3.31.1 function merge(arr1,arr2) { out_arr=[]; i=0; j=0; while (i<arr1.length && j<arr2.length) { if (arr1[i]<arr2[j]) {out_arr.push(arr1[i]); i++;} else if (arr1[i]>arr2[j]) {out_arr.push(arr2[j]); j++;} else { out_arr.push(arr1[i]); out_arr.push(arr2[j]); i++;j++; } } if (i<arr1.length) { out_arr.push(arr1[i]); i++; } if (j<arr2.length) { out_arr.push(arr2[j]); j++; } print(out_arr); } merge([2,5,6,9], [1,2,3,29]);
run
|
edit
|
history
|
help
0
GCD
single_digit
TaskhelTemplate
LazyListJS
Java - Looping thru Strings
Javascript Closure
javascript check undefined
What the hell is javascript
JS exam part 2 - Find the property
Probability