Learn Form Validation by Building a Calorie Counter - Step 43

Tell us what’s happening

targetInputContainer.querySelectorAll().

In last assignment we learn about DOM object and its syntax which was document.querySelector()
So, when to use variable like targetInputContainer in place of document.
If someday can explain

Your code so far

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

/* file: styles.css */

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

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  console.log(targetInputContainer);

}

// 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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 43

  • add a variable name as mentioned in instructions

So, when to use variable like targetInputContainer in place of document.
If someday can explain

  • when you want this to be true for entire doccument then go with “document” but only want to limits to specific div the go with fivs like “targetInputContainer”

hope this was useful, happy coding :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.