daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dec2bin(num){
  2.     var arr = [] , rem =0 , count = "";
  3.   var n = num;
  4.  
  5.   while( n > 0){
  6.     rem = Math.floor(n % 2);
  7.     arr.push(rem);
  8.     n = Math.floor(n /2);
  9.   }
  10.     //alert(arr);
  11.   while(arr.length !==0){
  12.     count += arr.pop();
  13.   }
  14.   return count;
  15. }
  16. alert(dec2bin(10));
RAW Paste Data
Top