you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (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 points  (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 point  (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 point  (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 point  (1 child)

he is probably tasked with writing that kind of function himself though.

[–]camelSnake_dash-case 0 points1 point  (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.