Binary Agents code Review

Hi guys. I know it’s probably not the best code ever. But I’d like to hear your opinion on how to make it clearer.

function binaryAgent(str) {
  let arrOfBin=str.split(' ');
  let arrOfDec=[];
  function toDecimal(num,arrayToPush){
    let arr=num.split("");
    let degree=num.length-1;
    let result=0;
      for (let i=0;i<arr.length;i++){
  for (let bin of arrOfBin){
  return String.fromCharCode(...arrOfDec);

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");

Well, you could use parseInt(), as much as your binary convertor is admirable, there is already a method that does that.

To make it more readable you are also missing comments in your code

1 Like

Oh yeah about that, it was intentional because I thought it would be beneficial to practice converting it by myself instead of using prebuilt methods.