Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertFromBinaryToDecimal(binaryNumber){
- let sum = 0;
- let position = 0;
- for(let i = binaryNumber.length-1;i>=0;i--){
- let currentDigit = Number(binaryNumber[i]);
- sum += currentDigit*(2 ** position);
- position++;
- }
- console.log(sum);
- }
- //Change the number if you want
- convertFromBinaryToDecimal('1010');
Add Comment
Please, Sign In to add comment