Tell us what’s happening:
Hello. I am stuck on this step, can someone please tell me what is wrong with my code.
Step 16
Call the decimalToBinary
function and pass in the value
of numberInput
as an argument. Also, make sure to use the parseInt()
function to convert the input into a number.
Your code so far
const numberInput = document.getElementById(“number-input”);
const convertBtn = document.getElementById(“convert-btn”);
const result = document.getElementById(“result”);
const decimalToBinary = (input) => {
};
const checkUserInput = () => {
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
alert(“Please provide a decimal number”);
return;
}
const decimalToBinary = (parseInt(numberInput.value));
};
convertBtn.addEventListener(“click”, checkUserInput);
numberInput.addEventListener(“keydown”, (e) => {
if (e.key === “Enter”) {
checkUserInput();
}
});
### Your browser information:
User Agent is: <code>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36</code>
### Challenge Information:
Learn Recursion by Building a Decimal to Binary Converter - Step 16
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-recursion-by-building-a-decimal-to-binary-converter/step-16