title: Javascript reduce gives incorrect values
body: <p>Consider the data to be</p>
  
  <pre><code>{
      "Groceries": [
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "85.14",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "19.15",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "4.2",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "16.08",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "28.48",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "35.82",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "12.15",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "4.19",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "34.11",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "3.36",
              "debit": true
          },
          {
              "category": {
                  "uri": "/categories/20fe3330-80e1-4908-9f57-5b7ef575b197",
                  "parent": "Food &amp; Drink",
                  "name": "Groceries"
              },
              "amount": "11.32",
              "debit": true
          }
      ],
      "Restaurants": [
          {
              "category": {
                  "uri": "/categories/15147702-8227-4ee8-8b05-d2e8d532bd0a",
                  "parent": "Food &amp; Drink",
                  "name": "Restaurants"
              },
              "amount": "18.43",
              "debit": true
          }
      ]
  } 
  </code></pre>
  
  <p>All I want this data to be in similar to something like</p>
  
  <pre><code>{
      "Groceries": 1234.12, # (1234.12 is madeup value for now)added values for all Groceries transaction
      "Restaurents": 18.42
  }
  </code></pre>
  
  <p>I am using <a href="http://lodash.com/docs#reduce" rel="nofollow">Lodash</a> to do this, my code looks like</p>
  
  <pre><code>var mapped = _.reduce(data, function(result, num, key){
    var sum = 0.0;
    sum = _.reduce(num, function(sum, n){
        console.log(key + ':' + parseFloat(n.amount));
        return sum + parseFloat(n.amount);
    });
    result[key] = sum;
    return result;
  }, {})
  </code></pre>
  
  <p>and the result i get is</p>
  
  <pre><code>"{
      "Groceries": "[object Object]19.154.216.0828.4835.8212.154.1934.113.3611.32",
      "Restaurants": {
          "category": {
              "uri": "/categories/15147702-8227-4ee8-8b05-d2e8d532bd0a",
              "parent": "Food &amp; Drink",
              "name": "Restaurants"
          },
          "amount": "18.43",
          "debit": true
      }
  }"
  </code></pre>
  
  <p>What is that I am doing incorrect here?</p>