Simple PIN validation
<p>Task:
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits.
If the function is passed a valid PIN string, return true, else return false.</p>

<p>My solution:</p>

<pre><code>function validatePIN (pin) {
  //return true or false
  if (!isNaN(pin) &amp;&amp; Number.isInteger(pin) &amp;&amp; pin.toString().length == 4 || pin.toString().length == 6) { 
    return true 
  } else { 
    return false 
  }
}
</code></pre>

<p>The only bug I get is when I pass 4 digits as a string (<code>"1234"</code>) - it equals <code>false</code>.</p>