settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: Find the biggest of 3 numbers in JavaScript

+2 votes

Write a JS function that finds the biggest of 3 numbers. The input comes as array of 3 numbers.

Examples:

Input:
5
-2
7

Output:
7


Input:
130
5
99

Output:
130


Input:
43
43.2
43.1

Output:
43.2


Input:
5
5
5

Output:
5


Input:
-10
-20
-30

Output:
-10

The output is the biggest from the input numbers.

asked in JavaScript category by user ak47seo
edited by user golearnweb

1 Answer

+2 votes

You can use Math.max for the shortest solution. Here is the js code:

function findBiggestNum(arrNum) {
    [num1,num2,num3]=arrNum;

    let maxNum = Math.max(num1, num2, num3);//use Math.max for the shortest solution
    console.log(maxNum);

}

findBiggestNum([130, 5, 99]);

 

answered by user icabe
...