js实现输入一个数组,实现数组元素能够组成的最大整数
第一个输入输出案例
input: [7, 5, 52, 3]
output: 75523
第二个输入输出案例
input: [21, 35, 34, 86]
output: 86353421
function maxNum(num){
for(var i = 0; i < numArr.length - 2; i++) {console.log(numArr[i + 1].toString().length)
if(numArr[i].toString().length == 1 && (numArr[i].toString()[0]==numArr[i + 1].toString()[0])) {
var k = numArr[i + 1];
numArr[i + 1] = numArr[i];
numArr[i] = k;
}
console.log(numArr)
}
var newArr = numArr.reverse().join('');
return(parseInt(newArr))
}