title: How to compare field values with the same data attribute in javascript
body: <p>How do I compare the values in the text fields with the same data attribute in javascript?</p>
  
  <pre><code>&lt;input type="text" name="a" id="a" data-common="candy" class="loop" value="2"&gt;
  &lt;input type="text" name="b" id="b" data-common="candy" class="loop" value="3"&gt;
  &lt;input type="text" name="c" id="c" data-common="ice" class="loop" value="7"&gt;
  &lt;input type="text" name="d" id="d" data-common="ice" class="loop" value="2"&gt;
  &lt;input type="text" name="e" id="e" data-common="water" class="loop" value="5"&gt;
  &lt;input type="text" name="f" id="f" data-common="water" class="loop" value="9"&gt;
  </code></pre>
  
  <p>What I want to do is to determine the higher value on each of the fields with common data attribute. If the common attribute is candy, then the program will compare the values 2 and 3. 
  My problem is I can't think up of a good algorithm to even start coding. Can you give me an idea? What do I need to do first.</p>