title: Return formatted object with only positive values
body: <p>I've an object of objects. Each of my nested object has a price as a nested array which may contain negative values. 
  I need to format the object and return a new one with the child objects containing only positive values.</p>
  
  <p>For e.g., 
  In the code below, ideally it should only return object with 'TypeB' object as only that has the price with non-negative values.</p>
  
  <p>I tried this, but I guess am missing something. 
  Also, can I optimize this using 'reduce' method instead?</p>
  
  <p>Input Object:</p>
  
  <pre><code>{
    "TypeA": [
      {
        "price": [
          [
            {
              "amount": -45,
              "currency": "USD"
            }
          ]
        ],
        "name": "ABC",
        "priceDetails": [
          {
            "name": "BASE",
            "price": [
              [
                {
                  "amount": -40.00,
                  "currency": "USD"
                }
              ]
            ]
          },
          {
            "name": "TAX",
            "price": [
              [
                {
                  "amount": -5.00,
                  "currency": "USD"
                }
              ]
            ]
          }
        ]
      }
    ],
    "TypeB": [
      {
        "price": [
          [
            {
              "amount": 0,
              "currency": "USD"
            }
          ]
        ],
        "name": "ABC",
        "priceDetails": [
          {
            "name": "BASE",
            "price": [
              [
                {
                  "amount": 0,
                  "currency": "USD"
                }
              ]
            ]
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>{
    "TypeB": [
      {
        "price": [
          [
            {
              "amount": 0,
              "currency": "USD"
            }
          ]
        ],
        "name": "ABC",
        "priceDetails": [
          {
            "name": "BASE",
            "price": [
              [
                {
                  "amount": 0,
                  "currency": "USD"
                }
              ]
            ]
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>const data = {
    "TypeA": [{
      "price": [
        [{
          "amount": -45,
          "currency": "USD"
        }]
      ],
      "name": "ABC",
      "priceDetails": [{
          "name": "BASE",
          "price": [
            [{
              "amount": -40.00,
              "currency": "USD"
            }]
          ]
        },
        {
          "name": "TAX",
          "price": [
            [{
              "amount": -5.00,
              "currency": "USD"
            }]
          ]
        }
      ]
    }],
    "TypeB": [{
      "price": [
        [{
          "amount": 0,
          "currency": "USD"
        }]
      ],
      "name": "ABC",
      "priceDetails": [{
        "name": "BASE",
        "price": [
          [{
            "amount": 0,
            "currency": "USD"
          }]
        ]
      }]
    }]
  };
  
  const formattedData = Object.values(data).filter(item =&gt; {
    return item.map(elem =&gt; {
      const itemPrice = elem.price;
      const isPositive = itemPrice[0][0].amount &gt;= 0;
      return isPositive ? elem : false;
    });
  });
  console.log(formattedData);
  </code></pre>