Sitemap
codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

JavaScript Arrays — Finding The Minimum, Maximum, Sum, & Average Values

4 min readJan 2, 2018

--

Press enter or click to view image in full size

Minimum value

Math.min(1,2,3,4)
// 1
Math.min([1,2,3,4])
// NaN
const arrMax = arr => Math.max(...arr);// IS THE SAME ASarrMax = function(arr){
return Math.max(...arr);
}

Maximum value

Sum of all values

arrSum = function(arr){
return arr.reduce(function(a,b){
return a + b
}, 0);
}

Average value

Closing Notes:

If this post was helpful, please click the clap 👏button below a few times to show your support! ⬇⬇

--

--

codeburst
codeburst

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Brandon Morelli
Brandon Morelli

Written by Brandon Morelli

Creator of @codeburstio — Frequently posting web development tutorials & articles. Follow me on Twitter too: @BrandonMorelli

Responses (10)