I have an array with some dates and values. Eg: In date x we have 20 orders, in date y we have 32 orders.
[2016-08-09: 38, 2016-08-08: 75, 2016-08-05: 13, 2016-08-04: 23, 2016-08-03: 10]
The second array is an array with all dates from last month. Eg:
["2016-07-14", "2016-07-15", "2016-07-16", "2016-07-17", "2016-07-18", "2016-07-19", "2016-07-20", "2016-07-21", "2016-07-22", "2016-07-23", "2016-07-24", "2016-07-25", "2016-07-26", "2016-07-27", "2016-07-28", "2016-07-29", "2016-07-30", "2016-07-31", "2016-08-01", "2016-08-02", "2016-08-03", "2016-08-04", "2016-08-05", "2016-08-06", "2016-08-07", "2016-08-08", "2016-08-09", "2016-08-10", "2016-08-11", "2016-08-12", "2016-08-13"]
Then I tried to map this arrays and check the date if is empty, write "" else write the value found in the first array.
var totalInputOrders = allDates.map(function(date) {
return [ date, inputOrdersCount[date] ? "" : inputOrdersCount[date] ];
});
It will give me an 31 length array with array elements with 2 values. Date => Value. If date is not found in the first array it writes "" but he cannot find the value in the first array. Where am I wrong in this matter?
["2016-08-09: 38"...]inputOrdersCount[date] ? inputOrdersCount[date] : ""or!inputOrdersCount[date] ? "" : inputOrdersCount[date]