Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //V1
- module.exports = function(context, cb) {
- const array = context.data.values;
- const result = array.reduce(function(a,b){return a*b;});
- cb(null, { result : result });
- };
- //V2
- /*
- SAMPLE INPUT:
- {
- "list": [
- {"values": [1.1,0.0087,2.04]},
- {"values": [1.1,0.027]},
- {"values": [1.1,0.0087,0.444]},
- {"values": [1.1,5,0.23387]}
- ]
- }
- */
- module.exports = function(context, cb) {
- const list = context.data.list;
- const results = [];
- list.forEach(function(elem, i){
- var array = elem.values;
- var temp_result = array.reduce(function(a,b){return a*b;});
- results.push(temp_result);
- })
- cb(null, { results : results });
- };
Add Comment
Please, Sign In to add comment