Input
Array =[4,2,8,11,14,6,1]
Expectedtotal=20
Output
[2,4,6,8], [11,8,1],[6,11,1,2],[2,14,4],[14,6]
code:
const arr = [4, 2, 8, 11, 14, 6, 1];
const target = 20;
res = _.filter(arr, v => _.filter(arr, v1 => _.filter(arr, v2 => _.filter(arr, v3 => v + v1 + v2 + v3 === target))); console.log(res);
I am the beginner of javascript and lodash. I tried this code by own..please help me to write good code.