Learn Form Validation by Building a Calorie Counter - Step 39

Tell us what’s happening: I’m stuck on step 38. I tried my best, and I’m out of idea.

Your code so far

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

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 39

You weren’t supposed to switch targetId with entryDropdown.value.

I would reset the step and try again.

This is my latest, still errors out:

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

}

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

}

Look at the original code again:

document.querySelector(targetId + ' .input-container');

Notice there is a space before the input-container class.

Also, you need to learn how to paste your code in properly here so we can see it. Use the following method to do that.

To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key. You may also be able to use Ctrl+e to automatically give you the triple back ticks while you are typing in the this editor and the cursor is on a line by itself. Alternatively, with the cursor on a line by itself, you can use the </> button above the editor to add the triple back ticks.

Thanks! I solved it. I had to remove an unnecessary “+”.

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