Learn Form Validation by Building a Calorie Counter - Step 58

Tell us what’s happening:I get this error messege: Sorry, your code does not pass. Don’t give up.

You should assign the result of your cleanInputString call to your currVal variable.

Your code so far:

    const currVal = item.value;
    currVal = cleanInputString(item.value);
    currVal = innerText.currVal;

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:123.0) Gecko/20100101 Firefox/123.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 58

You are assigning three different values to currVal in sequence. The result is that the value stored in currVal is innerText.currVal. Are you sure that is correct?

Hi @thomasVulpes
It is asking to have just one line. Before you made your changes you had:

const currVal = item.value;

Modify what you have done to be just one line using the cleanInputString() function instead of item.value

Pass the item.value as an argument, in your cleanInputString() .
@thomasVulpes

I just tried that. No success. my modified (unsuccessful) code:

const currVal = item.value;
    currVal = cleanInputString(item.value);

That didn’t work. my revised code:

const currVal = item.value;
    currVal = cleanInputString();

new error messege: Sorry, your code does not pass. Try again.

You should pass item.value as the argument for cleanInputString function.

That is what I had in the first place.

You are still using two lines. It is asking for just one line.

No success. my newer code:

currVal = cleanInputString(item.value);

new error messege: Sorry, your code does not pass. Keep trying.

You should assign the result of your cleanInputString call to your currVal variable.

Do not forget to include the const

I will give you some hints:

  1. Update your currVal declaration to be the result of calling cleanInputString with item.value.

  2. The currVal variable is a constant.

I have updated your posts to wrap the code inside code blocks.
That will make it easier to read on the forum

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

My newer code:

   const currVal = item.value;
    currVal = item.value(cleanInputString);

newer error messege: Sorry, your code does not pass. Keep trying.

You should call the cleanInputString function inside the getCaloriesFromInputs function.

You should go back to what you wrote here because that is closer to the correct answer

The thing this answer is missing is the const keyword because currVal is a variable

my new code:

const currVal = item.value(cleanInputString);

new error: Sorry, your code does not pass. Hang in there.

You should call the cleanInputString function inside the getCaloriesFromInputs function.

Reread through my previous reply and you will be able to fix the problem

hope that helps

const currVal = item.value(cleanInputString);

Now, the cleanInputString is in the wrong place. item.value is what needs to be there.

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