arr1 = [{2=>7}, {2=>3, 8=>1}, {2=>2, 5=>2}]
arr2 = [{2=>9.95, 5=>16.95, 8=>24.95}]
expected result [ 69.65 , 54.8 , 53.8 ]
Here is the calculation:
So arr1 is kind of the map for the second array.
So I need to loop through the array 1 and array 2 then match the key of the array 1 and array 2 then grab the value of array 1 and multiple by the value of array 2.
Now in the array 1 second index there are 2 key value pairs which it means I have to do what I have explained and then then sum up the findings in that hash.
Hope it make sense.
I can do it through lots of loops. Just want to see if there are better ways like using map, etc to be more efficient.
Thank you for your help.
arr2is not an array. Either it is badly named or wrong. Can you clarify?