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