javascript - For each array value check if it is in a json array. If it is skip json array for next iteration -
sorry if title little confusing. not sure how else put it...
i have array of dates:
var daterange = ["2017-08-21", "2017-08-22", "2017-08-23", "2017-08-24", "2017-08-25", "2017-08-26", "2017-08-27"];
i have json array of data contains date.
var jsonarray = [ { date: "2017-08-21", edit: false, text: "some text" }, { date: "2017-08-23", //notice skipped 2017-08-22 edit: false, text: "some text" }, ... ];
so want check jsonarray
each date in daterange
, , if daterange
isn't present of jsonarray
's dates, something.
the way doing doing indexof
each date in daterange
realized instance "2017-08-23"
compared "2017-08-21"
triggered, don't want this, "2017-08-23"
present in array...
does make sense?
thanks help!
i dont know if got want check if item in jsonarray
contains date in daterange
right?
you can like:
let yourkey = jsonarray.some((item) => { return daterange.contains(item.date) })
this return true
yourkey
if jsonarray item date matches daterange date. it?
[edit]
if want check every json array item , can do:
jsonarray.foreach((item) => { if (daterange.contains(item.date)) { // date in array, } else { // date not in array, else. } })
wiki
Comments
Post a Comment