Im not sure where my code is messing up here.. this is the error msg i get: 1. Your cleanInputString should call the replace method of str.
2. You should pass regex as the first argument to replace.
3. You should pass “” as the second argument to replace.
4. Your cleanInputString function should directly return the result of your replace method.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function cleanInputString(str) {
const regex = /[+-\s]/g;
cleanInputString.replace(regex, "");
return cleanInputString();
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 24
function cleanInputString(str) {
const regex = /[±\s]/g;
cleanInputString.replace(regex, “”);
}
console.log(cleanInputString()); ------not sure what to put in as the argument, when i add (regex, “”) that doesnt work either
error // 1. Your
cleanInputString
should call the
replace
method of
str
. 2. You should pass
regex
as the first argument to
replace
. 3. You should pass
""
as the second argument to
replace
. 4. Your
cleanInputString
function should directly return the result of your
its telling me to use regex as the first argument in (str) and then to use “” as the second argument. im not sure where to use .replace() since theres only cleanInputString(str) function and regex
i want to apply replace onto the value of regex >> /[±\s]/g; like it says but thats where Im stuck im not sure what to put it on becuase regex.replace() doesnt make sense and the only other thing there is the function itself which also isnt working
console.log is useful to test your code, if you reread the recommendation, it was to use console.log to wrap a call to your function so you could see the output of the function in the console, not to use it inside the function
thanks, yes im aware.. I suppose since I kept getting a perpetual error msg on the console anyway it wasnt going to help much in this instance since it didnt lead me toward using return anyway.. trial and error did