Click to See Complete Forum and Search --> : I need help with FUNCTION code!! THX


baby_20
12-09-2005, 03:22 AM
Write the code for a function name maxValue() with two parameters, named theArray and numValues. The Javascript function should use a loop and a conditional statement to FIND THE MAXIMUM VALUE IN THE ARRAY and then return the value.
The user of the page should populate the array by an inputbox (window.prompt) using a for loop.
It is asked as well that we use the parseInt() function to convert the input data to integer


<html><head>
<title>Vicky</title>


<script type="text/javascript">
function maxValue(theArray, numValues){
var maxValue = 0
for(i=0; i<theArray.length; i++)
if(theArray[i] > maxValue)
maxValue = theArray[i];


</script></head>
<body>
<form id="finalForm" name="finalForm">
<input name="button1" value="button1" type="button"><br>
<br>
<input name="text1" value="text1" size="20" type="text">
</form>





</body></html>

Kravvitz
12-09-2005, 04:48 AM
Why did you start this new thread?

Asking other people to do your homework for you is no way to learn how to program.

You haven't even done everything I suggested in the other thread.

Old thread. (http://www.webdeveloper.com/forum/showthread.php?t=87969)