0

I have the array "y" and it receives an array for each electric charge station that can be reserved. the "y" stands for the category of that place. That means that under the category "y" I have two places that take reservations and displayed in a calendar. In y[0] the are three objects, and in y[1] there is just one.

The object y[0][2] and y[1][0] have the same value in the keys "from" and "to".

from: '2017-05-06' to: '2017-05-06'

In that moment, is when I need to push a new disableDay into the calendarEvents array that will disable the day to be selected.

let y = [
[
    {
        from: '2017-05-03',
        place_id: 1,
        reservation_id: 1,
        to: '2017-05-04'
    },
    {
        from: '2017-05-15',
        place_id: 1,
        reservation_id: 2,
        to: '2017-05-17'
    },
    {
        from: '2017-05-06',
        place_id: 1,
        reservation_id: 3,
        to: '2017-05-06'
    }
],
[
    {
        from: '2017-05-06',
        place_id: 4,
        reservation_id: 6
        to: '2017-05-06'
    }
]];

How can code something that search for coincidences in those two values among objects of different arrays? ... and if that number is coincidences is equal to the y.length, then push it into the calendarEvents array.

boroboris
  • 1,548
  • 1
  • 19
  • 32
  • You may use lodash differenceWith (https://lodash.com/docs/4.17.4#differenceWith ) and `_.isEqual` as comparator. – Alina Loi Apr 25 '17 at 12:56
  • try looking at this answer. I think it's the simplest solution http://stackoverflow.com/a/1885569/5142901. – boroboris Apr 25 '17 at 13:45

0 Answers0