3
06/11/2024 5:27 अपराह्न
विषय प्रारंभकर्ता
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.
Examples:
Input:
"00001001"
Output:
9
Input:
"11110000"
Output:
240
The output should be printed to the console.
1 उत्तर
2
06/11/2024 5:28 अपराह्न
Here is the javascript programming code for the conversion:
function convertBToD(input) {
let binary = parseInt(input, 2);
console.log(binary);
}
convertBToD("11110000");
