src/lib/demo.js
function(arr) {
    var key = 0;
    var max = arr[0];
    for(var i = 1, len = arr.length; i < len; i++) {
      if(arr[i] > max) {
        key = i;
        max = arr[i];
      }
    }
    return key;
  }
function(arr) {
    var key = 0;
    var max = arr[0];
    for(var i = 1, len = arr.length; i < len; i++) {
      if(arr[i] > max) {
        key = i;
        max = arr[i];
      }
    }
    return key;
  }
function ( arr ) { var key = 0 ; var max = arr [ 0 ] ; for ( var i = 1 , len = arr . length ; i < len ; i ++ ) { if ( arr [ i ] > max ) { key = i ; max = arr [ i ] ; } } return key ; }
Get index of the maximal value within an array of numbers.
Get index of the maximal value within an array of numbers .