/    Sign up×
Community /Pin to ProfileBookmark

Can someone help me with this???? (find the maximum value in the ARRAY)

Im Viktoria from Hungary and I would appreciate if you can help me with this problem 😮

Regularly I never do this, but Im desperate to get this done…I was trying quite hard, but I think I was not made for this javacript…( dont believe that I ask to do it for me, I will post the code i wrote after it explain what this is about ?

code:
<html><head>
<title> Vicky </title>

<script type=”text/javascript”>
function maxValue(theArray, numValues){

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

</body></html>

In my university the gave me an assignment that is the following. ?

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

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 08.2005 — It is really simple. Make a variable [I]maxValue[/I]. Give it a value zero. Now loop through the array and every time an array value is greater than [I]maxValue[/I] replace [I]maxValue[/I] with the larger value.

[code=php]for(i=0; i<theArray.length; i++) if(theArray[i] > maxValue) maxValue = theArray[i];[/code]
×

Success!

Help @baby_20 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...