Learn Form Validation by Building a Calorie Counter - Step 44

Hello,
I am at step 44 of Learn Form Validation by Building a Calorie Counter.
The instruction is;

Start your HTMLString with a new line, then create a label element. Give that element the text Entry # Name , using your template literal syntax to replace # with the value of entryNumber .

This is my response;

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

The feedback I am getting is Your HTMLString variable should start with a new line.

Kindly let me know what I should correct
Thanks

When HTMLString is declared as const, it means it cannot be reassigned. The whole defining of the HTMLString value needs to happen during single assignment.

1 Like

what else mus I do, for even after using let, the feedback I am getting is is still Your HTMLString variable should start with a new line.

What’s your updated code?

Hi @pkwandera1

Since you are using template literals \n won’t work.
Delete it, then just press the enter key to move the rest of the code onto a new line.

Happy coding

3 Likes

Thanks a lot. I has worked

1 Like
HTMLString = `
  <label>Entry ${entryNumber} Name</label>`;
}

that one has now worked. thanks a lot.

Thank you for this., it is a great lesson. You are a star!

1 Like

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