Learn Form Validation by Building a Calorie Counter - Step 42

Tell us what’s happening: Its telling me to return the length all in the same line and I’m having a bit of trouble understanding how to do that. Below is my code.

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.

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
 const entryNumber = targetInputContainer.querySelectorAll(input[type="text"]); 
 return querySelectorAll.length;
}

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: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15</code>

### Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 42
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-form-validation-by-building-a-calorie-counter/step-42

querySelectorAll takes a string as an argument. You haven’t passed a string here. Remember, a string needs one of the various types of quotes available in JS around it.

return querySelectorAll.length;

The instructions aren’t asking you to create a return statement yet, so get rid of this. What the instructions are asking you to do is set the value of entryNumber to the length of the NodeList returned by querySelectorAll.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

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