Learn Form Validation by Building A Calorie Counter - Step 52

function addEntry() {
  const targetInputContainer = some code;
  const entryNumber = some code;
  const HTMLString = `some code`;
  targetInputContainer.innerHTML += HTMLString;

I’m doing this step in the Javascript course and it’s telling me to do the following:

Your other bug occurs if you add a Breakfast entry, fill it in, then add a second Breakfast entry. You’ll see that the values you added disappeared.

This is because you are updating innerHTML directly, which does not preserve your input content. Change your innerHTML assignment to use the insertAdjacentHTML() method of targetInputContainer instead. Do not pass any arguments yet.

The answer to that is to change the last line of code in the function “addEntry()”. So it would be this answer:

[Solution redacted]

It took me ages to realize that was what I had to do, since it is not explained at all in the paragraph, it does not mention anything related to deleting that bit of the code. For those who have the same problem, that is the answer.

It should be explained more clearly, since it can lead to misunderstanding and confusion.

Hi @mariodr0796, I see you are new to the forums, so this is just some friendly advice. Please don’t post working code solutions in the forum. We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

The instructions say:

“Change your innerHTML assignment to use the insertAdjacentHTML() method of targetInputContainer instead.”

The word “Change” seems to imply that you would delete some existing code and replace it with something else, so it seems like it would be implied that you are going to delete some code, but perhaps the word “Replace” might be a little clearer?

Personally, I think the more confusing aspect of this step is that it just tells you to use the insertAdjacentHTML method without explaining what this method is.

Hi @bbsmooth, sorry if that wasn’t very appropriate. It just makes me feel confused and a bit annoyed when something is not properly explained or information might be missing. It could be helpful to have some extra info to make things clear. Obviously, it’s a free resource, so it might be more difficult to do so.
I’ll try to be more careful next time. Thanks for your advice.