6 lines
203 B
JavaScript
6 lines
203 B
JavaScript
|
function bin_to_dec(bstr) {
|
||
|
return parseInt((bstr + '')
|
||
|
.replace(/[^01]/gi, ''), 2);
|
||
|
}
|
||
|
console.log(bin_to_dec('110011'));
|
||
|
console.log(bin_to_dec('100'));
|