Stuck converting Binary Agents

Tell us what’s happening:
I for the life of me cannot seem to figure out how to convert the binary to decimal properly. I’m confident that that is my only real issue. I’m trying to use doubling but I’m not quite sure what I’m doing wrong. Maybe I’m just not understanding how to do the conversion properly. Anyway advice is very much appreciated.

Your code so far

function binaryAgent(str) {
  let res = 0;
  let split = str.split(' ');
  let oneArr = split[0].slice();
  let bin = 0;
  let sum = 0;
  let newArr = [];

//gives each section one by one
function oneAtAtime(one){
      return one;
  //supposed to convert the binary to decimal by doubling
function double (i,j){
      return ( i * 2 + j);

  for (let i = 0; i < split.length; i++){
    (res = oneAtAtime(split[i]));
   (bin = (res));
   //supposed to push th edecimal of each binary into a new array 
   for(let i = 0, j = 1;i < bin.length, j < bin.length; i++, j++){
     sum = (double(bin[i],bin[j]));


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0

Challenge: Intermediate Algorithm Scripting - Binary Agents

Link to the challenge:

Thank you introducing me a new method to convert binary to decimal called “doubling”

But, actually there is an easy way, javascript parseInt . check out here → W3Schools Tryit Editor

Anyway, i refine your code to get the doubling to work :grinning:

for (let i = 0; i < split.length; i++){
// console.log(split)
bin = split[i];

let doublingResult = bin[0];               // initialise with 1st character
for(let i = 1 ; i < bin.length ; i++) {    // doubling starting from 2nd character
  doublingResult = double(doublingResult, parseInt(bin[i]))
// console.log(doublingResult)



It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.