nodejs binary string to decimal number

// Binary string
const binaryString = '1101101';

// Convert binary string to decimal number
const decimalNumber = parseInt(binaryString, 2);

// Output
console.log(decimalNumber);
  1. Declare a variable binaryString and assign a binary string to it.
  2. Use the parseInt function to convert the binary string (binaryString) to a decimal number. The second parameter 2 specifies that the input is in base-2 (binary).
  3. Store the result in the variable decimalNumber.
  4. Output the decimal number to the console.