How to convert char array from the end to start into a single int in TypeScript

1 Answer

0 votes
const arr : string[] = ['8', '7', '0', '9', '4'];
        
const n : number = parseInt(arr.reverse().join(''), 10);
        
console.log(n);




/*
run:

49078 

*/

 



answered Sep 23, 2022 by avibootz
...