JSFiddle - React, Tailwind, and code Playground

by sdgluck

HTML

<span></span>

JavaScript

var data = [{
  "G": "PIF",
  "H": "FOB",
  "I": "NINGBO",
  "J": "NGB",
  "K": "2014-10-01",
  "M": "2014-10-01",
  "Y": "LIVERPOOL",
  "zp": "LIV",
  "N": "2014-11-09",
  "P": "2014-11-09",
  "R": "2014-11-09T12:01",
  "V": true,
  "zk": " ",
  "zo": "7",
  "Customs": [
    "39210000",
    "39210000",
    "3921"
  ],
  "LatLon": {}
}];

function countUniqueCustomCodes (arr) {
  var counts = arr.map(function (obj) {
    var uniques = [];
    
    obj.Customs.forEach(function (str) {
      if (uniques.indexOf(str) === -1) {
        uniques.push(str);
      }
    });
    
    return uniques.length;
  });
  
  return counts.reduce(function (total, count) {
    return total + count;
  }, 0);
}

document.querySelector('span').innerText = countUniqueCustomCodes(data);