Learn Form Validation by Building a Calorie Counter - Step 24

Tell us what’s happening:

I've been trying for three days to see what I'm missing.
Any suggestions will be greatly appreciated.

function cleanInputString(str) {
const regex = /[±\s]/g;
str.replace(regex, “”);
}

Sorry, your code does not pass. Keep trying.

Your cleanInputString function should directly return 
the result of your replace method.

Your code so far

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

/* file: styles.css */

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

I’ve been trying for three days to see what I’m missing.
Any suggestions will be greatly appreciated.

function cleanInputString(str) {
  const regex = /[+-\s]/g;
  str.replace(regex, "");
}

Sorry, your code does not pass. Keep trying.

Your cleanInputString function should directly return
the result of your replace method.


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 24

Hi there. You seem to be almost there. There’s only one more thing you have to do. You need to return the modified string from the function. Are you familiar with how to do this?

Let me know if you need additional assistance. :slight_smile:

Thank you a2937. I’m not sure how to return the modified string from the function, but I can do some research to see what I can find. Thanks again.

a2937,
That was it! Thank you. All I had to do is put the return in front of the replace method.
:pray: