Learn Form Validation by Building a Calorie Counter - Step 78

Tell us what’s happening: Ive tried this a few other ways, and it keeps saying

You should access the innerHTML property of the output element…

Please help, there is a lot of confusion in this section.

Your code so far

const outputElement = document.getElementById(‘output’);

outputElement.innerHTML = ``;

“Start by assigning an empty template literal to the innerHTML property of the output element.”

output is the name of the variable you initialized near the top of your code that points to the #output div. That’s what you want to as the innerHTML property to.

I tried this as well to no avail:

const output = document.getElementById(‘output’);

output.innerHTML = ``;

To me it looks like I have assigned the empty template

You don’t need to do this again. You already did this in a previous step. You should see it near the top of your code.

Put the assigned empty template at the bottom of the function. And remove the outpuElement that you made, you already declared output at the top of the page.

Like this?

function calculateCalories(e) {
e.preventDefault();
isError = false;
output.innerHTML = ``;

Sorry, your code does not pass. Try again.

You should assign an empty template literal to the innerHTML property of the output element.

Yes, you are assigning the empty template string correctly, but the tests want you to put it at the end of the function.

1 Like

Passed it. Thank you.

2 Likes