Learn Form Validation by Building a Calorie Counter - Step 24

Tell us what’s happening:

I still having the “your cleanInputString function should directly return the result of your replace method.” Can someone point me where my code is not working? Thanks :slight_smile:

Your code so far

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

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

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1.1 Safari/605.1.15

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 24

please refer to the words “directly return”
you are not directly returning, you are first storing the output of replace in str, then returning it

also be aware that it’s not good practice to change values of the parameters

2 Likes