js对于数组[1,2, 3, 5, 6, 8, 10.11,12],数字连续用 表示.转成[-3,5...答:function sample(arr){ var res=[];pos=0;while(pos<arr.length){ str=""+arr[pos];temp=pos;while(pos<arr.length-1 && arr[pos]+1==arr[pos+1])pos++;if(pos>temp) str+="-"+arr[pos];res.push(str);pos++;} return res;} arr1=[1,2, 3, 5, 6, 8, 10,11,12]ale...