I need to find the highest number from 3 different numbers. The only thing I’ve found is max() but you can only use 2 numbers.
Whats the best way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Math.max function can accept any arbitrary number of arguments:
Syntax:
Usage:
For example:
You could even use it to get the maximum value of an array of numbers with the help of apply:
If you can target ES6 (ES2015), you can also use the spread operator: