Skip to content

Commit fd1025e

Browse files
LordKa0Sitsvinayak
andauthored
Fix methodname and parameter type in BinaryToDecimal.js (#392)
* Update BinaryToDecimal.js Fix typo in name * Update BinaryToDecimal.js Co-authored-by: vinayak <itssvinayak@gmail.com>
1 parent 2c5e1e7 commit fd1025e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Conversions/BinaryToDecimal.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
function binaryToDeicmal (binaryNumber) {
1+
const binaryToDecimal = (binaryString) => {
22
let decimalNumber = 0
3-
const binaryDigits = binaryNumber.split('').reverse() // Splits the binary number into reversed single digits
3+
const binaryDigits = binaryString.split('').reverse() // Splits the binary number into reversed single digits
44
binaryDigits.forEach((binaryDigit, index) => {
55
decimalNumber += binaryDigit * (Math.pow(2, index)) // Summation of all the decimal converted digits
66
})
7-
console.log(`Decimal of ${binaryNumber} is ${decimalNumber}`)
7+
console.log(`Decimal of ${binaryString} is ${decimalNumber}`)
8+
return decimalNumber
89
}
910

10-
binaryToDeicmal('111001')
11-
binaryToDeicmal('101')
11+
(() => {
12+
binaryToDecimal('111001')
13+
binaryToDecimal('101')
14+
})()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy