Function to return min_element index
function min_element ( arr ) { let idx = 0 ; let min = arr [ 0 ] ; for ( let i = 1 ; i < arr . length ; i ++ ) { if ( arr [ i ] < min ) { min = arr [ i ] ; idx = i ; } } return idx ; }