Update BinaryToDecimal.js

This commit is contained in:
Chaitanya Raj
2020-08-23 15:49:51 +05:30
committed by GitHub
parent 0e398bbe2f
commit b9c6491c79

View File

@ -1,6 +1,6 @@
function binaryToDeicmal (binaryNumber) {
let decimalNumber = 0
const binaryDigits = binaryNumber.split('').reverse() // Splits the bnary number in revered single digits
const binaryDigits = binaryNumber.split('').reverse() // Splits the binary number into reversed single digits
binaryDigits.forEach((binaryDigit, index) => {
decimalNumber += binaryDigit * (Math.pow(2, index)) // Summation of all the decimal converted digits
})