[해결로 표시] JavaScript의 바이너리에서 십진수로 변환

  

3
주제 스타터

Write JavaScript function that reads an 8-bit binary number and converts it to a decimal.

The input comes as one string element, representing a binary number.

예시:

입력:
"00001001"

출력:
9


입력:
"11110000"

출력:
240


The output should be printed to the console.

1개 답글
2

Here is the javascript programming code for the conversion:

function convertBToD(input) {
    let binary = parseInt(input, 2);
    console.log(binary);
}
 
convertBToD("11110000");
공유: