How to find the biggest number in array

How can I find the biggest number from the numbers I've entered in array?

things i've tried already:

var largest = Math.max.apply(Math, number[i]);
var smallest = Math.min.apply(Math, number[i]);

Answers


You're very close:

Math.max.apply(Math, number);

You need to pass all of the elements of the array to the max() metho; [i] doesn't make sense here.


Need Your Help

Elasticsearch empty an object

elasticsearch

New to ES. I am trying to create users index which will allow visitors to search users. To make sure that I can display profile pictures on search results, I also have an image object. My data look...

XCode Instruments 6 (by far) not reflecting the correct amount of memory

ios xcode memory instruments

I've a huge difference between the amount of used memory displayed in XCode debug panel and the same info in Instruments.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.