Learn Form Validation by Building a Calorie Counter - Step 44

Tell us what’s happening: I don’t know what am doing wrong, third eye please.

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 targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
  let HTMLString = ``;
  HTMLString = `
  <label>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/121.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 44

Please post your full code so the forum can assist.

function addEntry() {
const targetInputContainer = document.querySelector(#${entryDropdown.value} .input-container);
const entryNumber = targetInputContainer.querySelectorAll(‘input[type=“text”]’).length;
let HTMLString = ``;
HTMLString = <label>Entry ${entryNumber} Name</label>;
}

Hi @nikky.princess

You have let HTMLSting = ``;, which isn’t needed as the variable was already declared using the const keyword.
Then you have another HTMLString variable.

Please remove the code not asked for in the instructions, then try again.
To be safe though, copy the the label element, looks great, then reset the step to restore the original code.

Happy coding

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

still am getting this message in my console log “You should have a label element inside your template literal.
Your label element should have the text Entry ${entryNumber} Name.”

Hi @nikky.princess

Your code has two HTMLString variables.

I don’t know what else to do, am stuck here for days now.

I don’t know what else to do, am stuck here for days now.

Post your full code so the forum can assist.

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

Dont’ forget to declare the HTMLString with the const keyword.

Happy coding

Thank you just reset the step and its went well.

1 Like