Hey community, I can’t understand Why I’m unable to pass this challenge. It works just as intented, returning a string translated in english from the binary.
function binaryAgent(str)
{
var codeASCII=[],bincode,sum,power, reduce,stringAscii=[],curCode;
str=str.split(" ");
for(var i=0; i<str.length; i++)
{
bincode=str[i];
sum=0;
for(var j=0; j <bincode.length ;j++)
{
reduce=7-j;
if(bincode[reduce] === "1")
{
power=Math.pow(2,j);
sum=sum+power;
}
}
codeASCII.push(sum);
}
for( i=0; i<codeASCII.length;i++)
{
curCode=String.fromCharCode(codeASCII[i]);
stringAscii.push(curCode);
}
stringAscii=stringAscii.join(" ");
str=stringAscii;
return str;
}
For binaryAgent(“01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111”); it returns “Aren’t bonfires fun!?”