Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const func = (arr1) => (arr2) => (arr3) => {
- const arr = [arr1, arr2,arr3];
- const result = {
- total:0,
- idOfBiggest:0
- };
- let valueOfBiggest=0
- const sum = arr.map(x => {
- if (x.value > valueOfBiggest) {
- valueOfBiggest=x.value;
- result.total += x.value;
- result.idOfBiggest =x.id;
- }
- }
- );
- return result;
- }
- console.log(func({ id: 1, value: 7 })({ id: 2, value: 5 })({ id: 3, value: 654 }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement