mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 15:39:42 +08:00
Update BinaryToDecimal.js
This commit is contained in:
@ -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
|
||||
})
|
||||
|
Reference in New Issue
Block a user