title: How can I select the last 4 characters of a string using JavaScript?
body: <p>This code chooses the highest numerical value between the data ids and adds an lime background to it. btw these numbers are hex values.
  my problem is that in hex values its the matter of the last 4 values but my code takes the whole characters. how can i make my code work for only the last 4 characters?</p>
  
  <p>Im sorry this might be easy to solve for you but i tried over and over again and couldnt make it work.</p>
  
  <p>Hex to decimal: </p>
  
  <p>dc61 = 56417</p>
  
  <p>dc62 = 56418</p>
  
  <p>dc63 = 56419</p>
  
  <p>dc64 = 56420</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> maxData = $(".answers li[data-id]").get ().reduce  ( (maxObj, crrntNode) =&gt; {
   
      var idVal   = parseInt ( $(crrntNode).data("id"), 16) ; 
  
      if (idVal &gt; maxObj.value) {
          maxObj.value  = idVal;
          maxObj.node   = crrntNode;
      }
      return maxObj;
    },
    {value: 0, node: null}
  );
  $("body").append (`&lt;p&gt;The highest data-id value was ${maxData.value}.&lt;/p&gt;`)
  $(maxData.node).css ("background", "lime");</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="question-text" class="question sp-element border-radius active"&gt;What is favorite colour?&lt;/div&gt;
            &lt;ul class="answers" id="answers"&gt;
              &lt;li data-id="58b9890062279282090ddc61" class="answer sp-element border-radius active"&gt;Purple&lt;/li&gt;
              &lt;li data-id="58b9890062279282090ddc63" class="answer sp-element border-radius active"&gt;Blue&lt;/li&gt;
              &lt;li data-id="58b9890062279282090ddc64" class="answer sp-element border-radius active"&gt;Yellow&lt;/li&gt;
              &lt;li data-id="58b9890062279282090ddc62" class="answer sp-element border-radius active"&gt;Red&lt;/li&gt;
            &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>