Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var arr = [1,2,3,4,5,];
var result = arr.reduce(function(sum, nextValue) {
  return sum += nextValue;
});
           
           
           
1. first interation -- > sum(1) + next(2);
2. first interation -- > sum(3) + next(3);
3. first interation -- > sum(6) + next(4);
4. first interation -- > sum(10) + next(5) --> return 15;
           
Output 300px

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers