var sampleData = [
{
date_issued: '2018-05-25',
transaction_type: 'IMPORT',
policy_number: '061/100/001052/2018',
open_cover: false,
endorsement_number: '',
icc: 'ICC-A',
insured_name: 'SAYONA STEEL LTD',
insured_email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fc919590919d8ebc9b919d9590d29f9391">[email protected]</a>',
insured_tin: '103 286 883',
intermediary_name: 'MILMAR',
intermediary_tin: '100-714-078',
goods_category: 'Mineral Products',
country_of_origin: 'HK',
destination: 'Mwanza Region',
conveyance: 'SEA',
financier: '',
currency_code: 'USD',
exchange_rate_used: '2262.37',
sum_insured: '23302411',
premium: '33935.55',
VAT: '5176.609322',
unit_of_measure: 'UNITS',
quantity: '800',
cover_start_date: '2018-05-15'
},
{
date_issued: '2018-05-25',
transaction_type: 'IMPORT',
policy_number: '061/100/001051/2018',
open_cover: false,
endorsement_number: '',
icc: 'ICC-A',
insured_name: 'URHOME COMPANY LTD',
insured_email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbb6b2b7b6baa99bbcb6bab2b7f5b8b4b6">[email protected]</a>',
insured_tin: '132-209-898',
intermediary_name: 'MILMAR',
intermediary_tin: '100-714-078',
goods_category: 'Base Metals And Articles Of Base Metal',
country_of_origin: 'CN',
destination: 'Dar es Salaam Region',
conveyance: 'SEA',
financier: '',
currency_code: 'USD',
exchange_rate_used: '2262.37',
sum_insured: '54941202.98',
premium: '58821.62',
VAT: '8972.789492',
unit_of_measure: 'UNITS',
quantity: '2792',
cover_start_date: '2018-05-15'
}
];
const checkKeysExist = (sampleData, keys) => {
return sampleData.every(item => keys.every(key => item.hasOwnProperty(key)));
};
console.log(checkKeysExist(sampleData, ['VAT', 'currency_code']));
console.log(checkKeysExist(sampleData, ['VAT', 'unknown']));