Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
(function binaryConverter2(num) {
    var numString = num.toString(),
        total = 0,
        i = numString.length-1,
        j = 1;
    console.log(numString);//"1011010110100101000"
    while(i >= 0) {
        total += (numString[i] *j);
        j = j*2;
        i --;
        console.log(total);
    }
    return total;
}(1011010110100101001));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
jeremylarterpro
0viewers