Learn Form Validation by Building a Calorie Counter - Step 49

Tell us what’s happening:

Hi, my code does not pass, even i do not see any mistake. Can you help me?
My code so far:

<!-- file: index.html -->

/* file: script.js */
// User Editable Region


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" placeholder="Name" id="${entryDropdown.value}-${entryNumber}-name">`
}

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 49

Hi. You are lengthening your HTML string variable by the addition of the input element. You need to move the backtick and semi-colon after the closing label tag to the end.

1 Like

hi friend,
First, the semicolon within the HTMLString template literal should be removed. Second, the closing backtick and brace are missing from the HTMLString assignment.

try this :

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" placeholder="Name" id="${entryDropdown.value}-${entryNumber}-name"> ;
targetInputContainer.insertAdjacentHTML(‘beforeend’, HTMLString);
}

1 Like

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