I am working with a Record
Here is an example input:
const input1 = {
key1: [
[2002, 10],
[2003, 50],
],
};
const input2 = {
key1: [
[2002, 20],
[2003, 70],
],
};
const input3 = {
key1: [
[2002, 5],
[2003, 60],
],
};
For each key, I want to calculate the following for each specific year:
year => input1 + input2 - input3
// output: 2002 => 25, 2003 => 60
To achieve this, I have been experimenting with lodash/fp.
map(a => a.map(nth(1)))(map('key1')([input1, input2]))
// [[10, 50], [20, 70], [5, 60]]
Is there a way to pass the inputs and iterate over them, then get a callback function to retrieve the values needed for the calculation?
I have tried using zip
and zipWith
, but have not made much progress. Any suggestions on what I can do in this scenario? Thank you for your assistance.