Hello,
Quick question
why in the code I need launch
decimalToBinary(inputInt)
and not directly decimalToBinary()
and then why do I need the “input” in const decimalToBinary = (input) => {};
then why something like this is not working :
convertBtn.addEventListener("click", checkUserInput);
const checkUserInput = () => {
const b = parseInt(numberInput.value);
if (!numberInput.value || isNaN(b)) {
alert("Please provide a decimal number");
return;
}
if (b === 5) {
showAnimation();
return;
}
result.textContent = decimalToBinary();
numberInput.value = "";
}
const decimalToBinary = () => {
const a = parseInt(numberInput.value)
if (a === 0 || a === 1) {
return String(a);
} else {
const c = (decimalToBinary((a / 2)) + (a % 2));
return String(c);
}
};
I belive I’ve miss the key information at some point
thanks
Challenge Information:
Learn Recursion by Building a Decimal to Binary Converter - Step 109