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
Star wars ep 3. limit
Functions
JavaScript - CheckDate()
More testing with JS
My Code1
Triangle
Javascript Basics If statements
LearningJavaScript
Jason's Code Challenge
@@@@@