Learn Form Validation by Building a Calorie Counter - Step 40

Tell us what’s happening:

I am having issues here it says i should Use concatenation to separate targetId and ‘.input-container’ with a space, and pass that string to querySelector().

Your code so far


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

}

Does anyone have an ideal on what i should do.Thanks so much in advance

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 40

“Use concatenation to separate targetId and '.input-container' with a space, and pass that string to querySelector().”

You are only passing targetId to querySelector(). You want to pass the concatenation to querySelector().

How can this be done please explain further, i am confused

Can you explain what you are confused about? Do you not know how to pass a string to a function? Do you not know how to concatenate two strings into one?

I can my problem is i don’t know where to pass a string function, am i creating a new variable?

I can tell you that the tests do not want you to create a new variable. Your solution should only be one line of code.

You do know how to concatenate strings:

targetId + ' .input-container'

This is exactly what the instructions are asking you to do. Now you just need to do this part:

“… pass that string to querySelector()

wow i just got it thanks ʘ‿ʘ

1 Like