loading
open in
index.js
1
2
3
4
5
6
7
8
9
10
const largestNumber = (numArr) => {
 numArr.sort((a, b) => {
    return parseInt(`${b}${a}`) - parseInt(`${a}${b}`);
  });    
  return parseInt(numArr.join(''));
}

console.log(`Largest Number: ${largestNumber([50, 2, 1, 9, 5])}`); // 955021 - PASS
console.log(`Largest Number: ${largestNumber([50, 5, 56])}`); // 56550 - PASS
console.log(`Largest Number: ${largestNumber([420, 42, 423])}`); // 42423420 - PASS
node v10.15.2 linux/amd64