Answers for "math method to return the largest number javascript"

5

javascript hwo to return largest value with index

var a = [0, 21, 22, 7];
var indexOfMaxValue = a.reduce((iMax, x, i, arr) => x > arr[iMax] ? i : iMax, 0);

document.write("indexOfMaxValue = " + indexOfMaxValue); // prints "indexOfMaxValue = 2"
Posted by: Guest on August-21-2020
0

Find Largest Number by function by javascript

function largestNumber(first, second, third) {
    if (first > second && first > third) {
        return first;
    } else if (second > first && second > third) {
        return second;
    } else {
        return third;
    }
}
const num1 = 100;
const num2 = 120;
const num3 = 80;
console.log(largestNumber(num1, num2, num3));
//Output: 120
Posted by: Guest on December-16-2021

Code answers related to "math method to return the largest number javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language