This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.
Find the maximum value in an array. function max(col, fn) { var top = - Infinity ; var index; if ( Array .isArray(col)) { for ( var i = 0 ; i < col.length; i ++ ) { var result = col[i]; if ( typeof fn === 'function' ) { result = fn(col[i]); } else if ( typeof fn === 'string' ) { result = col[i][fn]; } if (result >= top) { top = result; index = i; } } } return typeof index !== 'undefined' ?…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.