Learn Form Validation by Building a Calorie Counter - Step 38

Tell us what’s happening:

I would like some help on this step. I get an error message that says:
" Sorry, your code does not pass. You’re getting there.

You should concatenate ' .input-container' to targetId. Remember to include the space at the beginning of .input-container."

What am I missing on this step? Thank you

Your code so far

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

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 38

Hello @camaguncoso
Originally you had:

const targetId = '#' + entryDropdown.value;

And that doesn’t get changed in any way at this point.

Everything is done on this:

const targetInputContainer = document.querySelector(targetId);`

The document.querySelector is missing the concatenation requested with .input-container

I just did this and I get an error message

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

The closing parenthesis after targetId no longer should live there.

Sorry, your code does not pass. You’re getting there.

Your targetInputContainer variable should be set to document.querySelector().

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

I removed the target parenthesis and error again

Tha parenthesis has to enclose the whole expresseion from “targetId”

1 Like

The parenthesis need to exist but not how it was.

1 Like

Thank you for your assistance. I appreciate it

Also, this might not be super obvious, but if you see a blank line in the starting code that means you are adding new code to that line. If the challenge was asking you to change the first line it wouldn’t have a blank line after it. Just an FYI.

1 Like

I will take that into consideration

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