Learn Form Validation by Building a Calorie Counter - Step 41

Tell us what’s happening:

Have been stuck on this request -
Your addEntry function should have a targetInputContainer variable??

function addEntry() {
  const targetId = '#' + entryDropdown.value;
  const targetInputContainer = document.querySelector('#'{entryDropdown.value} .input-container);

}

### Your code so far


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

/* file: styles.css */

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

function addEntry() {
  const targetId = '#' + entryDropdown.value;
  const targetInputContainer = document.querySelector('#'{entryDropdown.value} .input-container);

}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 41

Hi there!

The instructions is asking you: Declare a new targetInputContainer variable, and assign it the value of document.querySelector(). Use concatenation to separate targetId and .input-container with a space, and pass that string to querySelector().

But aren’t concatenating the targetId with .inputContainer. instead you have added a # and dropdown.value

isn’t ‘#’ + entryDropdown.value the targetId?

No, it’s not.

That’s the targetId variable. That’s stores the id in it

So you need to use the variable instead of actual value.

I am still missing something …

const targetInputContainer = document.querySelector(targetId  .input-container);

Because you haven’t concatenating (+) the variable targetId and '.input-container'. also you you need to add the exact’ .input-container` to the querySelector() after concatenate symbol.

Ah, ok that worked! Thank you for your help:)

1 Like