Learn Form Validation by Building a Calorie Counter - Step 39

Tell us what’s happening:

Your code so far

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.

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

Hint: You should use a template literal in your querySelector method.

Please tell me I don’t have a syntax error!

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 can’t use the variable templateLiteral here because it isn’t defined in your code. That was just a variable used in the example.

it is defined in my code.

Ahh, I see, I missed that because I wasn’t expecting it. Sorry about that.

You don’t want to use a temporary variable here. Pass the template literal string itself into document.querySelector.

thanks. hope it works! it did!

1 Like
function addEntry() {
  const targetId = "#" + entryDropdown.value;
  const targetInputContainer = document.querySelector(`${targetId} .input-container`);
}

Must write it like that, the code has passed !!!