Learn form validation by building a calorie counter step 44

i am having problem getting past this step , it says my code should have a label element inside it but i dont get how it means

const calorieCounter = document.getElementById('calorie-counter');
const budgetNumberInput = document.getElementById('budget');
const entryDropdown = document.getElementById('entry-dropdown');
const addEntryButton = document.getElementById('add-entry');
const clearButton = document.getElementById('clear');
const output = document.getElementById('output');
let isError = false;

function cleanInputString(str) {
  const regex = /[+-\s]/g;
  return str.replace(regex, '');
}

function isInvalidInput(str) {
  const regex = /\d+e\d+/i;
  return str.match(regex);
}

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


  
}

Link your topic to the challenge step.

Hi @awaisraf201

Step 44 Inside your template literal, create a label element and give it the text Entry # Name. Using your template literal syntax, replace # with the value of entryNumber.

You added too much code for this step.

Happy coding

i did that i think, but it still didnt work, even asked chatgpt for help but no luck

Blockquote const HTMLString = <label for="entry-${entryNumber}">Entry ${entryNumber} Name:</label>;

Blockquote

Inside your template literal, create a label element and give it the text Entry # Name . Using your template literal syntax, replace # with the value of entryNumber .

Still too much code:

  1. place the label element on a new line
  2. the instructions did not ask for an attribute, so please remove it.
  3. Name does not have a colon after it

Happy coding

1 Like

i understand, thank you for the help

1 Like