前端笔试练习五

var a = [-3,-1,0,1,3,5,7,9], b = [-4,-2,0,2,3,4,5,6,7,8];返回一个合并过的数组[-4,-3,-2,-1,0,0,1,2,3,3,4,5,5,6,7,7,8,9

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 //var a = [-3,-1,0,1,3,5,7,9], b = [-4,-2,0,2,3,4,5,6,7,8];
 6 //返回一个合并过的数组[-4,-3,-2,-1,0,0,1,2,3,3,4,5,5,6,7,7,8,9
 7 <script type="text/javascript">
 8 window.onload = function(){
 9   var a = [-3,-1,0,1,3,5,7,9], 
10   b = [-4,-2,0,2,3,4,5,6,7,8];
11   alert(combine(a,b));
12 }
13 function combine(a,b){
14   var array = a.concat(b);
15   return array.sort();
16 }
17 </script>
18 </head>
19 
20 <body>
21 </body>
22 </html>
原文地址:https://www.cnblogs.com/allenxing/p/3311401.html