fork(2) download
  1. let num=[1,2,3,4,5,6];
  2. let sum=num.reduce(myfun);
  3. function myfun(total,value)
  4. {return total+value};
  5. console.log("Total="+sum);
  6. console.log("Mean="+sum/num.length)
Success #stdin #stdout 0.02s 16892KB
stdin
Standard input is empty
stdout
Total=21
Mean=3.5