How to realize the operation of array summation, maximum and minimum by js
This article mainly shows you the "js how to achieve array summation, maximum, minimum operation", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "js how to achieve array summation, maximum, minimum operation" this article.
Array summation, maximum, minimum
Const array = [5, 4, 7, 8, 9, 2]
Array summation:
Array.reduce ((aformab) = > aforb)
Array maximum:
Array.reduce ((a) b) = > a > b? A: B); Math.max (. Array)
Array minimum:
Array.reduce ((a) b) = > a < b? A: B); Math.min (. Array)
The evaluation problem of most groups can be solved by using the reduce method of arrays.
These are all the contents of the article "how to achieve array summation, maximum and minimum operation in js". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!