I have a very complex logic problem. I have to compare 4 arrays and get them to work together. I'll explain better
Example of how you can come:
var mesA = [ "fev", "mar", "jun" ]
var valorA = [ 50, 50, 50 ]
var mesB = [ "jan", "fev", "mar", "jul", "ago" ]
var valorB = [ 25, 25, 25, 25, 25 ]
var mesA_Final = []
var valorA_Final = []
var mesB_Final = []
var valorB_Final = []
How should the output of this be:
var mesA_Final = [ "jan", "fev", "mar", "jun", "jul", "ago" ]
var valorA_Final = [ 0, 50, 50, 50, 0, 0 ]
var mesB_Final = [ "jan", "fev", "mar", "jun", "jul", "ago" ]
var valorB_Final = [ 25, 25, 25, 0 25 25 ]
I need to make a comparison of these 2 arrays, order them by the name of the month, and compare the two arrays so that they take their differences and insert value 0
in the month that one has and the other does not, and vice versa. / p>
Obs¹: These 4 arrays will always come with correct month and value, if for example 3 months, 3 values will come.
Obs2: What will come in the array of arrays is dynamic, can come 1 month 1 value, how can 2 months come 2 values, 3 months 3 values
The most I got was this: JSFiddle
Does anyone have an idea?