My Reduce

easy
Implement your own myreduce method which returns the sum of an array. 
       You must not create a separate function for myreduce.
       You must use prototyping for implementation.

Sample of reduce method:
const array1 = [1, 2, 3, 4];
const reducer = function(accumulator, currentValue){return accumulator + currentValue;}

// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer));
// expected output: 10

// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));
// expected output: 15

Input Format

NA

Output Format

NA

Constraints

NA

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input

        
Output

        
Previous
Dev Scrapping
Next
Scrapping 2

Related Questions