const shots = [
{id: 1, amount: 2},
{id: 2, amount: 4},
{id: 3, amount: 52},
{id: 4, amount: 36},
{id: 5, amount: 13},
{id: 6, amount: 33}
];
shots.reduce((acc, shot) => acc = acc > shot.amount ? acc : shot.amount, 0);
Math.max(...arr.map(({ value }) => value));
Math.max.apply(Math, array.map(function(o) { return o.y; }))
let objects = [{id: 0, votes: 5}, {id: 1, votes: 3}, {id: 2, votes: 11}]
let maxObj = objects.reduce((max, obj) => (max.votes > obj.votes) ? max : obj);
/* `max` is always the object with the highest value so far.
* If `obj` has a higher value than `max`, then it becomes `max` on the next iteration.
* So here:
* | max = {id: 0, votes: 5}, obj = {id: 1, votes: 3}
* | max = {id: 0, votes: 5}, obj = {id: 2, votes: 11}
* reduced = {id: 2, votes: 11}
*/
<!DOCTYPE html>
<html>
<body>
<p>By using Math.max.apply method we can find out the maximum array value</p>
<p>The maximum aray value is:</p>
<p id="pId"></p>
<script>
var marks = [40, 95, 70, 45, 75, 55];
document.getElementById("pId").innerHTML = maximumArayValue(marks);
function maximumArayValue(array) {
return Math.max.apply(null, array);
}
</script>
</body>
</html>