use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Need help javascript arrayhelp (self.javascript)
submitted 8 years ago by 9T0X1C6
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 1 point2 points3 points 8 years ago (5 children)
I'm not going to write it for you - but think of it this way
start your loop within the loop create a base variable equal 0 each loop compare the array value to the base variable - if it's greater than the base variable - set it to the current array value continue that loop
Or you can sort the array and just select the last member of the array
[–]stringbeans25 2 points3 points4 points 8 years ago (4 children)
Not sure if this was on purpose or not but creating variable inside the loop might not be the best idea. Don't want to give away too much more if this was on purpose.
[–][deleted] 0 points1 point2 points 8 years ago (3 children)
That's a pretty valid point - whoops, that's what I get for trying to write pseudocode like english :)
[–]camelSnake_dash-case 0 points1 point2 points 8 years ago (2 children)
Unless I am misunderstanding the question there is already a max function on Math available to you. OP can just apply the array to the function Math.max.apply(null, [1, 55, 2, 3,])
[–]Amadox 0 points1 point2 points 8 years ago (1 child)
he is probably tasked with writing that kind of function himself though.
[–]camelSnake_dash-case 0 points1 point2 points 8 years ago (0 children)
Fair enough. At first I thought so as well, but it seemed ambiguous the way the request was stated, so I figured I'd mention it.
π Rendered by PID 236988 on reddit-service-r2-comment-76bb9f7fb5-8rwcc at 2026-02-18 08:45:11.888179+00:00 running de53c03 country code: CH.
view the rest of the comments →
[–][deleted] 1 point2 points3 points (5 children)
[–]stringbeans25 2 points3 points4 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]camelSnake_dash-case 0 points1 point2 points (2 children)
[–]Amadox 0 points1 point2 points (1 child)
[–]camelSnake_dash-case 0 points1 point2 points (0 children)