Hi guys, I'm trying to build 2 arrays from JSON arrays.
{ "2015-03-24": { "bind": 0, "info": "", "notes": "", "price": "150", "promo": "", "status": "available" }, "2015-03-25": { "bind": 0, "info": "", "notes": "", "price": "150", "promo": "", "status": "available" }, "2015-03-26": { "bind": 0, "info": "", "notes": "", "price": "150", "promo": "", "status": "available" }, "2015-03-27": { "bind": 0, "info": "", "notes": "", "price": "100", "promo": "", "status": "available" }, "2015-03-28": { "bind": 0, "info": "", "notes": "", "price": "100", "promo": "", "status": "available" }, "2015-03-29": { "bind": 0, "info": "", "notes": "", "price": "100", "promo": "", "status": "available" }, "2015-04-10": { "bind": 0, "info": "", "notes": "", "price": "", "promo": "", "status": "booked" }, "2015-04-11": { "bind": 0, "info": "", "notes": "", "price": "", "promo": "", "status": "booked" }, "2015-05-01": { "bind": 0, "info": "", "notes": "", "price": "", "promo": "", "status": "unavailable" }, "2015-05-02": { "bind": 0, "info": "", "notes": "", "price": "", "promo": "", "status": "unavailable" }, "2015-05-03": { "bind": 0, "info": "", "notes": "", "price": "", "promo": "", "status": "unavailable" }, }
This is a jSon array,
So, I want to build 2 arrays.
1 array containing only the keys (in this case the date) of those elements where status=='booked' nOR status=='unavailable' , and builds it in a jQuery array like this
var array = ['2015-03-19', '2015-03-20', '2015-03-21', '2015-03-22', '2015-03-23', '2015-03-24', '2015-03-25', '2015-03-26', '2015-04-07', '2015-04-08', '2015-04-09', '2015-04-10'];
Another creates another array with the dates of those days when status=='available' AND price > '100$'
var array2 = ['2015-03-25', '2015-03-26', '2015-04-07', '2015-04-08'];
How can I achieve this with jQuery ??