Learn Form Validation by Building a Calorie Counter - Step 21

Tell us what’s happening:

Hello there! I’m trying to complete a task, but I’ve run into some issues. On the bottom and sides of the developer console, I see the following messages: “Sorry, your code didn’t pass. You’re on track.”
The regex variable should be set to “/+-\s/”, but it’s not working properly.
Could you please help me figure out what’s wrong and how to fix it? Your assistance would be greatly appreciated.
Thank you!

Your code so far

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

/* file: styles.css */

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

function cleanInputString(str) {
    
    const regex = /[\+\-\s]/g; 
    return 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/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 21

Hi there!

The instructions is not asked to add [ ] and a slash \ between + and -.
Always strictly follow the instructions.

1 Like

Thank you very much for help.

1 Like