Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Algorithms/Find maximum/jscript

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

function findMax(intA) { if ( intA.length == 0 ) return 0; if ( intA.length == 1 ) return 1; var o_intMax = intA[0]; for (var p_intI = 1; p_intI < intA.length; p_intI++) { if ( intA[p_intI] > o_intMax ) { o_intMax = intA[p_intI]; } // end if } // end loop return o_intMax; } // end method var intA = new Array(1,9,6); document.write(findMax(intA));