Print alternate elements of an array | Function to print Alternate elements of the given array ; Print elements at odd positions ; Print elements of array ; Driver Code
function printAlter ( arr , N ) { for ( var currIndex = 0 ; currIndex < N ; currIndex += 2 ) { document . write ( arr [ currIndex ] + " " ) ; } } var arr = [ 1 , 2 , 3 , 4 , 5 ] ; var N = 5 ; printAlter ( arr , N ) ;