Javascript: use of Array#some and Array#every on nested array elements

I have this key/value object:

{
   "march 2021 - monday": [
      {
         "day": "MONDAY",
         "date": "2021-03-01",
         "timetables": [
            {
               "day": "MONDAY",
               "slots": [
                  "09:00 - 09:30",
                  "09:30 - 10:00",
                  ...
               ],
               "changed": false
            },
            {
               "day": "MONDAY",
               "slots": [
                  "14:00 - 14:30",
                  "14:30 - 15:00",
                  ...
               ],
               "changed": false
            }
         ]
      },
      {
         "day": "MONDAY",
         "date": "2021-03-08",
         "timetables": [
            {
               "day": "MONDAY",
               "slots": [
                  "09:00 - 09:30",
                  "09:30 - 10:00",
                  ...
               ],
               "changed": false
            },
            {
               "day": "MONDAY",
               "slots": [
                  "14:00 - 14:30",
                  "14:30 - 15:00",
                  ...
               ],
               "changed": false
            }
         ]
      }
   ],
   "march 2021 - tuesday": [
      {
         "day": "TUESDAY",
         "date": "2021-03-09",
         "timetables": [
            {
               "day": "TUESDAY",
               "slots": [
                  "07:00 - 07:30",
                  "07:30 - 08:00",
                  ...
               ],
               "changed": false
            }
         ]
      }
   ],
   "march 2021 - thursday": [
      {
         "day": "THURSDAY",
         "date": "2021-03-18",
         "timetables": [
            {
               "day": "THURSDAY",
               "slots": [
                  "10:00 - 10:30",
                  "10:30 - 11:00",
                  ...
               ],
               "changed": false
            }
         ]
      }
   ]
}

I would like to:

  • return true when there is a "changed": true for at least one timetable for every date property;
  • otherwise return false;

I make this
codepen
where there are a couple of attempts. The second attempt seems to work but I’m not sure. Do you think this is correct?
Is there another way to get what I want?

Thanks

95 thoughts on “Javascript: use of Array#some and Array#every on nested array elements”

  1. pharmacie tanguy annecy pharmacie auchan pontet , pharmacie bailly tensiometre pharmacie bourges place planchat , [url=https://kit.co/debpoe/ayurslim-sans-ordonnance-luxembourg-ayurslim-prix-sans-ordonnance#]Ayurslim Ayurslim 60 capsules[/url] pharmacie beauvais jean rostand [url=https://kit.co/ranxe/celebrex-sans-ordonnance-quebec-celebrex-vente-libre#]Celebrex pharmacie QuГ©bec[/url] , pharmacie euratlantique bordeaux pharmacie ouverte 24/24 , pharmacie de garde marseille aujourd’hui. pharmacie rue president favre annecy therapies breves val-d’oise [url=https://kit.co/lieman/kytril-vente-libre-acheter-kytril-2-mg-pas-cher#]Kytril Granisetron 2 mg[/url] , pharmacie de beaulieu wattrelos. pharmacie dufournet annecy, pharmacie en ligne treated psychiatre therapie comportementale et cognitive gard . therapies esseniennes, therapies digitales therapie de couple marseille therapie de couple nantes .

    Reply

Leave a Comment