Learn Form Validation by Building a Calorie Counter - Step 44

it’s giving the error HTMLString should start with a new line can anyone tell me where am i making the mistake

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
  const HTMLString =`\n<label for="entry${entryNumber}">Entry ${entryNumber} Name</label>`;
}

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 44

Two things:

  • Don’t add a for attribute on the label. You are correct that it does need one, but you are jumping the gun here. You will add it in the next step. The tests don’t like it that you are adding it early :slightly_smiling_face:

  • The tests want an actual “return” in there, not a \n. It shouldn’t make a difference, and personally, I would use a \n here as well. But if you want to make the tests happy then get rid of the \n and put an actual return in there.

Also, I see that someone has already opened a github issue for this return bug. So this should be fixed soon.

function addEntry() {
const targetInputContainer = document.querySelector(#${entryDropdown.value} .input-container);
const entryNumber = targetInputContainer.querySelectorAll(‘input[type=“text”]’).length;
const HTMLString = <label>Entry #${entryNumber.value} </label>;
return HTMLString;
}
I’m still not able to solve this.

@arnavg34 Please create your own post for this using the Help button in the step.

1 Like

the new line they instructor meant there was indenting your code in a new line by clicking enter

solution

const myNewLine = `
//your code goes here
`

[solution removed]

@chijiokerichy

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

okay sir, i understand.

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