And initialize arr [ i ] as 0 means the element ' i + 1' is not seen so far
arr [ i ] = 0 ; i ++ ; } } document . write ( " " ) ; for ( let j = 0 ; j < n ; j ++ ) document . write ( j + 1 + " " + Math . abs ( arr [ j ] ) + " " ) ; }