Learn Form Validation by Building a Calorie Counter - Step 44

Tell us what’s happening:

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.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 44

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 = <br> <label>Entry ${entryNumber} Name</label>;

}

Hi @ranga.munyoro

You need to wrap the html elements in template literals.
HTMLString cannot use the br element.

Happy coding

I did as below:

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

But I am still getting the below message:

Sorry, your code does not pass. You’re getting there.

Your HTMLString variable should start with a new line.

After the first template literal press the enter key to move the rest of the code on to a new line.

1 Like

Wow. That’s some magic. It worked! How does that work though because I had no idea that pressing an enter would create a new line line. I was under the impression that
creates a new line. I am just confused cause I thought I had things figured out.

2 Likes