<script> function dec(num) { if (isNaN(num)) return; return parseInt(num, 10).toString(2); } console.log(dec("10")); </script>