const array = [5,4,7,8,9,2]; // Sum in array javascript array.reduce((a,b) => a+b); array.reduce((total, item) => total + item); // Output: 35 // MAX in array javascript array.reduce((a,b) => a>b?a:b); // For max, this is way faster: Math.max(...array); // Output: 9 // MIN in array javascript array.reduce((a,b) => a<b?a:b); // For min this is way faster Math.min(...array); // Output: 2
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter