We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Warmup
- Simple Array Sum
- Discussions
Simple Array Sum
Simple Array Sum
Sort by
recency
|
3353 Discussions
|
Please Login in order to post a comment
java 8:
Could you help me integrate this script into my page? I want to use it on my WordPress website.
For javascript using reduce method is the standard and easiest way to achieve this in a single line.
`
reduce method having default accumulation parameter which will add all the values of the element
Here is my c++ solution, you can watch the explanation here : https://youtu.be/b7KAvErmVIw
my solution to use JS
function simpleArraySum(ar) { // Write your code here return ar.reduce((a, b) => a + b, 0); }