Learn Form Validation by Building a Calorie Counter - Step 50

Tell us what’s happening:

I’m having a problem with calling the eventListener. The code I’ve inputted does not give the results required. I am looking for ways to fix this and I tried using google. Maybe I am not familiar with searching solutions like this on google

Your code so far

  const addEntryButton = document.querySelector('#addEntryButton');

  function addEntry() {
    console.log("Entry added");

  addEntryButton.addEventListener('click', addEntry);

// User Editable Region

// User Editable Region

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 50

can you provide your html and js file clearly separated?
it looks like you have an html element in your javascript, and that is not accepted syntax

I’ve edited the code

do you need to do this? or the button is already selected? like on line 4

If went back and forth adding and removing that. When I remove it, the code does not pass to tell me that it’s error

What is it that I’m doing wrong when the code does not pass?

Hi @camaguncoso

You already declared the addEntryButton variable one line four.

const addEntryButton = document.getElementById(‘add-entry’);

You do not need to declare it again, so you can delete it, as @ilenia suggested.

The instructions did not ask you to declare an addEntry function, so delete that as well.

Happy coding