Learn Recursion by Building a Decimal to Binary Converter - Step 84

Tell us what’s happening:

Describe your issue in detail here.
not sure what to do but its telling me that " The animationData array should have a length of 1 ."

Your code so far

/* file: script.js */
const numberInput = document.getElementById("number-input");
const convertBtn = document.getElementById("convert-btn");
const result = document.getElementById("result");
const animationData = [

/* User Editable Region */

animationData = {
    inputVal: 5,
    marginTop: 300,
    addElDelay: 1000
  }

/* User Editable Region */

];

const decimalToBinary = (input) => {
  if (input === 0 || input === 1) {
    return String(input);
  } else {
    return decimalToBinary(Math.floor(input / 2)) + (input % 2);
  }
};

const showAnimation = () => {
  setTimeout(() => {
    console.log("free");
  }, 500);
  setTimeout(() => {
    console.log("Code");
  }, 1000);
  setTimeout(() => {
    console.log("Camp");
  }, 1500);
};

const checkUserInput = () => {
  const inputInt = parseInt(numberInput.value);

  if (!numberInput.value || isNaN(inputInt)) {
    alert("Please provide a decimal number");
    return;
  }

  if (inputInt === 5) {
    showAnimation();
    return;
  }

  result.textContent = decimalToBinary(inputInt);
  numberInput.value = "";
};

convertBtn.addEventListener("click", checkUserInput);

numberInput.addEventListener("keydown", (e) => {
  if (e.key === "Enter") {
    checkUserInput();
  }
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn Recursion by Building a Decimal to Binary Converter - Step 84

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

All you want inside the array is the object, the animationData = part is not valid.

Remove that so you are left with just this inside the array.

{
    inputVal: 5,
    marginTop: 300,
    addElDelay: 1000
}
2 Likes

you need use something like: “inputVal” : 5,
2 lines below similar