mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
Update BinaryToDecimal.js
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
function binaryToDeicmal (binaryNumber) {
|
function binaryToDeicmal (binaryNumber) {
|
||||||
let decimalNumber = 0
|
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) => {
|
binaryDigits.forEach((binaryDigit, index) => {
|
||||||
decimalNumber += binaryDigit * (Math.pow(2, index)) // Summation of all the decimal converted digits
|
decimalNumber += binaryDigit * (Math.pow(2, index)) // Summation of all the decimal converted digits
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user