Code:
<script language="javascript">
/* maximum and minimum number within given number */
var arr = new Array(10,5,20,7,18);
var maxnum = 0;
for(var i=0;i<arr.length;i++){
if(arr[i]>maxnum){
maxnum = arr[i];
}
}
alert("The Heighst number is: "+maxnum);
for(var i=0;i<arr.length;i++){
if(arr[i]<maxnum){
maxnum = arr[i];
}
}
alert("The Lowest number is: "+maxnum);
</script>
Comments
Post a Comment