Answers for "find largest number in array javascript using for loop"

1

find largest number in array javascript using for loop

var peopleData = [
    { name: "Paul", height: 180, age: 21 },
    { name: "Johnny", height: 198, age: 43 },
    { name: "Brad", height: 172, age: 49 },
    { name: "Dwayne", height: 166, age: 15 }
];

//Find biggest height number
var maxHeight = 0;

for (var i = 0; i < peopleData.length; i++) {
    if (peopleData[i].height > maxHeight) {
        maxHeight = peopleData[i].height;
    }
}
Posted by: Guest on May-19-2021
5

javascript largest number in array

const max = arr => Math.max(...arr);
Posted by: Guest on July-02-2020
8

get largest number in array javascript

const array1 = [1, 3, 2];

Math.max(...array1);
// expected output: 3
Posted by: Guest on August-07-2020

Code answers related to "find largest number in array javascript using for loop"

Code answers related to "Javascript"

Browse Popular Code Answers by Language