Learn Form Validation by Building a Calorie Counter - Step 22

Tell us what’s happening:

it keeps rejecting my code. it says i should not escape + character in my regular expression. i am really confused.

Your code so far

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

/* file: styles.css */

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

function cleanInputString(str) {
  const regex = /[\+-\s]/;
}

// 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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 22

the hint says:

Your regex variable should be set to the regular expression [+-\s].
1 Like

thank you it worked! i must confess that javascript is very tough for me but i am trying best to understand these concepts…

1 Like

if you have a specific question about something that is confusing, let us know

1 Like

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