Learn Form Validation by Building a Calorie Counter - Step 24

Tell us what’s happening:

const regex = str.replace(regex/[± " "]/g, “”);
return regex;

why is not working on step 24

Step 24JavaScript provides a .replace() method that enables you to replace characters in a string with another string. This method accepts two arguments. The first argument is the character sequence to be replaced, which can be either a string or a regex pattern. The second argument is the string that replaces the matched sequence.Since strings are immutable, the replace method returns a new string with

Your code so far

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

/* file: styles.css */

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

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

}

// 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/127.0.0.0 Safari/537.36 Edg/127.0.0.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 24

Hi there!

You need to return that statement.