The clearBtn.addEventListener is working. I am able to remove the content within the result div.
However when I run the test, it does not qualify the number 6 requirement, which is to remove the content from the result div. Is my code not considered since it is quite different from the example project? Mine doesn’t store the numbers inputted, but mine clears the input when inputted once, even just putting string on the input w/out checking clears it.
Can you post your variable declarations for results-div and userInput?
Assuming they are correctly done, I think you only need these 2 lines in your clearfields function to clear user story 6:
userInput.value = ‘’;
resultDiv.textContent = ‘’;
I can see an addEvent Listener with a click and linking to the function but it needs to be at the end of the code not the start. InnerHTML works also instead of textContent.
userInput.value = ‘’;
resultDiv.textContent = ‘’;
Can you please put 3 backticks before and after your code to format it. When I put your HTML and JS in it had a lot of formatting errors with the single quotes and backslashes.
However, your clearfields function only needs this for it to pass:
userInput.value = ‘’;
resultDiv.innerHTML = ‘’;
Can you remove everything else? it is possibly an issue that your existing function has a return within the first if statement so nothing is happening after that. I can also see there is a missing ; after (‘hidden’) but again the user story 6 doesn’t require that.
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
See this post to find the backtick on your keyboard. Note: Backticks (`) are not single quotes (').
You have a conditional inside clearFields that is preventing the test from passing. The clear button should not depend on the content of the input element.