< ;title>Get the maximum value of the array
<script> <br>//Define the array<br>var arr = [1,4,3,9,5,0, -1,7,22]; <br><br>//The subscript of the maximum value is first assumed to be the subscript of the first element <br>var index = 0; <br>for(var x = 0; x < arr.length; x ){ <br><br>if(arr[index] < arr[x]){ <BR>index = x; <BR>} <BR>} <br><br>document.write("The index is the "arr[index] "maximum" in " index "); <br><br></script>