regex
as said before?
I don’t understand what you are asking about, can you write a complete sentence?
The question is related to regex
, so would this be the parameter
parameter is called a word goes within a function’s round()
braces. In that case the parameter is str
and regex
is in that case a variable storing a regular regex expression in the above function cleanInputString
no, it’s a variable. the parameters are defined when the function is called, their names are what goes here inside the round parenthesis when a function is defined. And they get a value when the function is called.
The console says str
is the right parameter to use…
what are you talking about? use where?
The tutor prompt says " Your cleanInputString
should call the replace
method of str
"
and you were not doing that in the code you shared, I was referring to that
which you changed in the next code snippet back to str
.
You are still missing using regex
, and the second argument for replace
Do you mean this?:
function cleanInputString(str) {
const regrex = /[+-\s]/g;
str[regrex].replace(/+-/g);
return(str[regrex]);
}
regex
isn’t an index of str
. You need an one linear return statement. That returns str
chaining with .relpace()
method. In the replace round braces, you need to add the regex
variable and a empty ""
string, separate both the regex
and ""
by a comma.
as such?:
function cleanInputString(str) {
const regex = /[+-\s]/g;
str.replace(/+-/g);
return(str.replace(regex,""));
}
Remove the above line.
Remove the outer round braces in this line.
But the exercise asks for two tasks performed not just one…
The instructions says: Use your regex to replace all instances of +, -, and a space in str with an empty string. Return this value.
It’s not saying two create two lines of code. They say code str.replace() and put regex and string in it then return the same line by adding return
keyword Infront of it.
If you feel the instructions are not correct , create an issue on Freecodecamap GitHub repository about the challenge step.
Replace all of that with this
code removed by moderator
hi @bunnybonze
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.