Skip to content

Instantly share code, notes, and snippets.

@heriipurnama
Last active May 27, 2019 04:35
Show Gist options
  • Save heriipurnama/c215daf39ee33869f3097d0efadf4345 to your computer and use it in GitHub Desktop.
Save heriipurnama/c215daf39ee33869f3097d0efadf4345 to your computer and use it in GitHub Desktop.
Distinct same value on two array object on reactjs
var avalableChannels =
[
{channel_id: "1", channel_name: "Channel A", created_date: null, access_name: "Channel A"},
{channel_id: "10", channel_name: "MKIOS", created_date: "2019-02-19T04:21:17.000Z", access_name: "mkios"},
{channel_id: "2", channel_name: "Channel B", created_date: null, access_name: "Channel B"},
{channel_id: "8", channel_name: "UPX", created_date: "2018-12-24T17:00:00.000Z", access_name: "UPX"},
{channel_id: "9", channel_name: "Channel C", created_date: "2019-01-09T17:00:00.000Z", access_name: "Channel C"}
];
var coupons1 = [
{evt_id_reff: "D1042", source: "SYSTEM", channel: "MKIOS", offer_id: "-", package_name: "-"},
{evt_id_reff: "D1042", source: "SYSTEM", channel: "Channel B", offer_id: "-", package_name: "-"}
];
const filteredDataPrize = [];
avalableChannels.map(coupon => {
if (
coupons1.findIndex(d => d.channel === coupon.channel_name) === -1
) {
filteredDataPrize.push(coupon);
}
});
console.log('filteredDataPrize: ',filteredDataPrize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment