Learn Form Validation by Building a Calorie Counter - Step 24

Tell us what’s happening:

Hi guys,

I can’t figure out what is it that I wrote wrong in this replace method of str. Could anyone please assist me?

Your code so far

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

const calorieCounter = document.getElementById(‘calorie-counter’);

const budgetNumberInput = document.getElementById(‘budget’);

const entryDropdown = document.getElementById(‘entry-dropdown’);

const addEntryButton = document.getElementById(‘add-entry’);

const clearButton = document.getElementById(‘clear’);

const output = document.getElementById(‘output’);

let isError = false;

function cleanInputString(str) {

const regex = /[±\s]/g;

“±\s”.replace(/±\s/g, “”);

}


### Your browser information:

User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0</code>

### Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 24
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-form-validation-by-building-a-calorie-counter/step-24

Hi,
The function receives a string, so you have to replace something from the str (string) not " +\s ". As you can see the regex is a const that has the values to be replaced from the string so you don’t need to add the values, just add regex instead.
Hope this helps.
regex

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