title: Check the number of digits after the decimal part
body: <p>I need to validate a number accordingly to its number of digits after the decimal part.</p>
  
  <p>I am using with success the following code but, I would like to know:</p>
  
  <ul>
  <li>Is there another better way to achieve the same result? Maybe using some native Math functional.</li>
  </ul>
  
  <p>Notes: I am aware of regular expression, but I am looking for a math approach.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    var max = 2; // max number of digits after decimal places
          var value = 10.154;
          var s = value.toString().split('.')
          if (s[1].length &gt; max) {
              alert('invalid');
          } else {
              alert('ok');
          }</code></pre>
  </div>
  </div>
  </p>