Concatenate the Array of elements into a single element | Function to find the integer value obtained by joining array elements together ; Stores the resulting integer value ; Traverse the array arr [ ] ; Stores the count of digits of arr [ i ] ; Update ans ; Increment ans by arr [ i ] ; Return the ans ; Input ; Function call
function ConcatenateArr ( arr , N ) { let ans = arr [ 0 ] ; for ( let i = 1 ; i < N ; i ++ ) { let l = Math . floor ( Math . log10 ( arr [ i ] ) + 1 ) ; ans = ans * Math . pow ( 10 , l ) ; ans += arr [ i ] ; } return ans ; } let arr = [ 1 , 23 , 456 ] ; let N = arr . length ; document . write ( ConcatenateArr ( arr , N ) ) ;