Guest User

Untitled

a guest
Jan 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //V1
  2. module.exports = function(context, cb) {
  3. const array = context.data.values;
  4. const result = array.reduce(function(a,b){return a*b;});
  5. cb(null, { result : result });
  6. };
  7.  
  8.  
  9. //V2
  10. /*
  11. SAMPLE INPUT:
  12. {
  13. "list": [
  14. {"values": [1.1,0.0087,2.04]},
  15. {"values": [1.1,0.027]},
  16. {"values": [1.1,0.0087,0.444]},
  17. {"values": [1.1,5,0.23387]}
  18. ]
  19. }
  20. */
  21.  
  22. module.exports = function(context, cb) {
  23.  
  24. const list = context.data.list;
  25. const results = [];
  26.  
  27. list.forEach(function(elem, i){
  28. var array = elem.values;
  29. var temp_result = array.reduce(function(a,b){return a*b;});
  30. results.push(temp_result);
  31. })
  32.  
  33. cb(null, { results : results });
  34.  
  35. };
Add Comment
Please, Sign In to add comment