Created
January 16, 2017 04:32
-
-
Save think2011/a9249b503094b4c69dfb8f534abdc87f to your computer and use it in GitHub Desktop.
合并和排序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [1, 2, 45, 88]; | |
var b = [3, 7, 8]; | |
var flag = 0; | |
for (let i = 0; i < b.length; i++) { | |
if (b[i] <= a[flag] || flag > a.length) { | |
a.splice(flag, 0, b[i]); | |
} else { | |
i--; | |
} | |
flag++; | |
} | |
console.log(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment