Learn Form Validation by Building a Calorie Counter - Step 24

Tell us what’s happening:

I dont know what might be wrong. Help please.
I’ve tried every syntax I can think of, but still doesn’t pass

Your code so far

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

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

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

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 24

You don’t need to create an additional variable here. You have used the replace method correctly but you can create a one-line return statement by prefixing the return keyword directly to it.

3 Likes

thank you so much.
This worked!

phewww

1 Like