Learn Form Validation by Building a Calorie Counter - Step 45

Tell us what’s happening:

You should pass the string input[type=“text”] to the querySelectorAll() method.

Pass the string input[type=“text”] to the querySelectorAll() method. This will return a NodeList of all the text inputs in the form. You can then access the length property of the NodeList

function addEntry() {
const targetInputContainer = document.querySelector(#${entryDropdown.value} .input-container);
const entryNumber = targetInputContainer.querySelectorAll(‘input[type=“text”]’.length);
}

Your code so far

<!-- file: index.html -->

/* file: script.js */
// User Editable Region

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

// User Editable Region
/* file: styles.css */

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 45

Hi @sweetmelissa235

You should pass the string input[type="text"] to the querySelectorAll() method.

The hint message will guide you on the next issue.

Happy coding

would it not pass through with querySelectorAll(‘input[type=“text”])’

I figured it out. the last part at the end was within the parenthesis and should have been outside. I was doing the pass through correctly. sometimes the error messages confuse me.

1 Like