Learn Form Validation by Building a Calorie Counter - Step 42

Tell us what’s happening:

Tutorial asks to access the length of the NodeList. I did this with NodeList.length; but the code does not pass.
It instead tells me to access the length property of your querySelectorAll(). I changed NodeList.length to querySelectorAll().length; but it gives me the same error.

Your code so far

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]');  querySelectorAll().length;
}

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 Edg/120.0.0.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 42

1 Like

Hey @jermynsoup

This is the bit that you are missing

Pass the string input[type="text"] to the querySelectorAll()

So inside the querySelectorAll() pass in 'input[type="text"]
Happy coding

3 Likes
  • Read the last instruction very carefully the hint is already given in that.
1 Like

here’s your solution
Mod edit: removed

Here’s another solution to the problem, in case anyone else needs a different explanation.

First, don’t forget to use single quotes where needed AND think of adding the needed property at the end of the line.