title: Reducing on Results obtained by jquery selector
body: <p>The code I used looks something like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    var total = $('#exam-percent-weightage &gt; td &gt; input').not('[type=hidden]').not('[disabled=disabled]').get().reduce(function(a, b) {
      return specialParseFloat(a === undefined ? 0 : a.value) + specialParseFloat(b === undefined ? 0 : b.value);
    });
    console.log(total);
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;tr id="exam-percent-weightage"&gt;
    &lt;td class="weightagePadding"&gt; &lt;strong&gt;First Term&lt;/strong&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;input name="data[Exam][0][percent_weightage]" class="form-control percentWeight" value="0.00" step="any" id="Exam0PercentWeightage" type="number"&gt;
      &lt;input name="data[Exam][0][id]" class="testId" value="30" id="Exam0Id" type="hidden"&gt;
    &lt;/td&gt;
    &lt;td&gt;&amp;nbsp;%&lt;/td&gt;
    &lt;td class="buttonPadding"&gt;+&lt;/td&gt;
    &lt;td class="weightagePadding"&gt; &lt;strong&gt;Second Term&lt;/strong&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;input name="data[Exam][1][percent_weightage]" class="form-control percentWeight" value="0.00" step="any" id="Exam1PercentWeightage" type="number"&gt;
      &lt;input name="data[Exam][1][id]" class="testId" value="31" id="Exam1Id" type="hidden"&gt;
    &lt;/td&gt;
    &lt;td&gt;&amp;nbsp;%&lt;/td&gt;
    &lt;td class="buttonPadding"&gt;+&lt;/td&gt;
    &lt;td class="weightagePadding"&gt; &lt;strong&gt;Third Term&lt;/strong&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;input name="data[Exam][2][percent_weightage]" class="form-control percentWeight" value="0.00" step="any" id="Exam2PercentWeightage" type="number"&gt;
      &lt;input name="data[Exam][2][id]" class="testId" value="32" id="Exam2Id" type="hidden"&gt;
    &lt;/td&gt;
    &lt;td&gt;&amp;nbsp;%&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;strong&gt;=&lt;/strong&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;input class="form-control" disabled="disabled" id="total-weight" type="number"&gt;
    &lt;/td&gt;
    &lt;td&gt;&amp;nbsp;%&lt;/td&gt;
    &lt;td class="buttonPadding"&gt;
      &lt;button type="submit" class="action-mainbtn"&gt;Save&lt;/button&gt;
    &lt;/td&gt;
  &lt;/tr&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Note: The jQuery version I have to use is actually 1.12.1  (which was not available in SO snippet tool)</p>
  
  <p>FYI: I've defined specialParseFloat and the error is probably not related to that. Anyway the function is as follows:</p>
  
  <pre><code>function specialParseFloat(something) {
      return parseFloat(something) || 0;
  }
  </code></pre>
  
  <p>The behavior I am getting in my browser (FF) is that reduce only returns the last value instead of adding all the values in the input box. This however works correctly with the case of having only two inputs. </p>
  
  <p>What did I do incorrect?</p>