Learn Form Validation by Building a Calorie Counter - Step 46

Tell us what’s happening:

Guys, pls tell me what’s wrong? It keeps telling me “You should have a label element inside your template”

Your code so far

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

/* file: styles.css */

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

  const HTMLString = `<label>Entry ${entryName} Name<\label>`;
  }

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Linux; arm_64; Android 13; RMX3191) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.49 YaBrowser/24.4.6.49.00 SA/3 Mobile Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 46

wrong slash, change it to be the other way /
if you keep having errors post again with your new code

  const HTMLString = `<label>Entry ${entryName} Name</label>`;

Have tried to change it one more time (I’ve tried both / and ), still error…

can you please give more of your code? maybe all the addEntry function

Sure

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>Entry ${entryName} Name</label>`;
  }

try putting this on a line of its own, the starting code had an empty line between the backticks where you should write

You are also using the wrong variable

replace # with the value of entryNumber .

You are not using entryNumber

Thank you, that was the point