title: Trying to convert lodash code to es6 methods; it's throwing error?
body: <p>so below commented out code is working in lodash just wanted to convert into es6 to make it simpler and clearer code its throwing error some is undefined. any help here ?</p>
  
  <p>main.js</p>
  
  <pre><code>        const rejectMessagerrors = [45,67,87];
          const drug = [{
              "isBrand": true,
              "drugName": "Lipitor",
              "specialtyPrice": {}
            },
            {
              "isBrand": false,
              "drugName": "Atorvastatin Calcium",
              "drugStrength": "80mg",
              "drugForm": "Tablet",
              "mailPrice": {
                "totalQuantity": 90,
                "rejectMessage": [{
                  "settlementCode": "45",
                  "settlementDesc": "Sorry, the system is temporarily:Lo sentimos,Intente(Código de error 85)"
                }]
              },
              "retailPrice": {
                "totalQuantity": 30,
                "rejectMessage": [{
                  "settlementCode": "99",
                  "settlementDesc": "Sorry, the system is temporarily:Lo sentimos,Intente(Código de error 85)"
                }]
              },
              "specialtyPrice": {}
            }
          ];
  
              function priceFilterHandler(drug) {
                  // const pricePath = ['mailPrice.rejectMessage', 'retailPrice.rejectMessage'];
    //
    // _.forEach(pricePath, function (path) {
    //   const rejectMsg = _.get(drug, path);
    //   const hasCode = rejectMsg &amp;&amp; rejectMsg.find(i =&gt; !!~rejectMessagerrors.indexOf(+i.settlementCode));
    //   hasCode &amp;&amp; delete drug[path.split('.').shift()];
    // });
    const retailHasCode = findErrCode(item.retailPrice.rejectMessage);
    const mailHasCode = findErrCode(item.mailPrice.rejectMessage);
  
    if (retailHasCode) {
      delete item.retailPrice;
    }
  
    if (mailHasCode) {
      delete item.mailPrice;
    }
  
    return item;
              }
  
     const filteredPrices = _.map(drug, priceFilterHandler);
  </code></pre>
  
  <p>findErr method </p>
  
  <pre><code>let findErrCode = data =&gt; {
    data.some(i =&gt; rejectMessagerrors.includes(+i.settlementCode));
  }
  </code></pre>
  
  <p>expected output</p>
  
  <p>Because <code>mailPrice</code> in contains settlementCode 45 that price should be omitted it matches the <code>rejectMessagerrors</code> list element</p>
  
  <pre><code>[{
                  "isBrand": true,
                  "drugName": "Lipitor",
                  "specialtyPrice": {}
                },
                {
                  "isBrand": false,
                  "drugName": "Atorvastatin Calcium",
                  "drugStrength": "80mg",
                  "drugForm": "Tablet",
                  "retailPrice": {
                    "totalQuantity": 30,
                    "rejectMessage": [{
                      "settlementCode": "99",
                      "settlementDesc": "Sorry, the system is temporarily:Lo sentimos,Intente(Código de error 85)"
                    }]
                  },
                  "specialtyPrice": {}
                }
              ];
  </code></pre>