javascript - Combine 2 arrays and fill with 0 if they are not duplicates -
i have 2 arrays datetimes. want display values in x-axis of chart.
i need function combine arrays in 1 , add '0' aren't duplicates.
array 1 = [2016-01-20,2016-01-21,2016-01-24] array 2 = [2016-01-21] final array = [0, 2016-01-21, 0]
is there quick way this?
thank much
var array1 = ['2016-01-20', '2016-01-21', '2016-01-24'] var array2 = ['2016-01-21'] var final = array1.map(function(e) { return (array2.indexof(e) == -1) ? e = 0 : e; }); console.log(final)
Comments
Post a Comment