Home:ALL Converter>compare the elements of an array in filter with other elements of another array

compare the elements of an array in filter with other elements of another array

Ask Time:2020-04-07T04:19:56         Author:Chahmeldine

Json Formatter

I try to display a row of 'availabilities, but I would like to exclude availability with similar values ​​to the values ​​of an element from another array' date '

start time end time and duration

  1. how to compare them to the other element of the 'date' array?
  2. how to compare only one specific value just the duration for example?
var date: [{
      client: 'jessica',
      start: '10:00',
      end: '10:30',
      duration: 30,
    },

    {
      client: 'joe',
      start: '11:00',
      end: '12:00',
      duration: 60,

    }
  ],

  var availabilities: [{
        start: '10:00',
        end: '10:30',
        duration: 30,
      },


      {

        start: '11:00',
        end: '12:00',
        duration: 60,

      },

      {
        start: '12:00',
        end: '13:00',
        duration: 60,

      },

      {
        start: '13:00',
        end: '14:00',
        duration: 60,

      },


    ],


    {
      disponibilitie.filter(availabilities =>
        availabilities.start !== date.start &&
        availabilities.end !== date.end &&
        availabilities.duration !== date.duration).map((availabilities) => {
        return ( <option value = {
            availabilities.duration
          } >
          {
            availabilities.start
          } - {
            availabilities.end
          } </option>
        )
      })
    }

expected result : { start: '12:00', end: '13:00', duration:60,js

Author:Chahmeldine,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61068292/compare-the-elements-of-an-array-in-filter-with-other-elements-of-another-array
yy