Learn localStorage by Building a Todo App - Step 67

Tell us what’s happening:

The question asks to create a removespecialchars() function which is done here, whats wrong

Your code so far

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

/* file: styles.css */

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

removeSpecialChars();

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

Challenge Information:

Learn localStorage by Building a Todo App - Step 67

Hi,
You sure they are the same?

Am I sure they are the same with…

I thought there was a problem in terms of capitalzing.
is it removespecialchars() or removeSpecialChars() wanted?

removeSpecialChars is what is in the question great one

Okay. The step wants you to define a function not call the function. See if you can do that.

You mean like this?:

function removeSpecialChars();

Hi there!

It’s a function call, you need to defines a function.

You are getting there. I think you have learned to create arrow functions in the previous step. For reference an arrow function looks like this:

const myFuncton= (parameter) => {
    return "Hello!"; 
};

Now this step wants you to create a function that takes an input string and removes the special characters.

not sure what you mean by an inout string?

My bad. I meant an input string. The function should take a string as a parameter and then remove the special characters from that string.

for example the function below takes message as a parameter and then prints it.

const myFuncton= (message) => {
    console.log(message);
};

like this?

const removeSpecialChars = () => {

};

Hi there!

that takes a string as input and removes all special characters.

To implement that functionally, you need to chain .replace() method to the paramater. The replace() method takes two arguments. For removing special characters, you need to add a regex pattern as a first argument within the replace() method and an empty string as a second argument then return that value within the function.

1 Like

Yes. great job. Now your function has to take a string and remove the special characters from it. To do that as hasanzaib suggested, you have to use .replace method.

1 Like

Here’s a Link you may find helpful.

1 Like

like this?:

const removeSpecialChars = (removeSpecialChars.replace(/[^a-zA-Z0-9]/g, "")) => {
  return removeSpecialChars();
}

removeSpecialChars is the name of the function, you can’t chain it to the .replace() method, nor you can add the the .replace() method as a parameter.

You are returning the function call within the same function, that’s also incorrect.

How did you add a parameter to a function?
How did you return that parameter within the function.

so what is the .replace to be chained to

Review the function definition here:

To the parameter of the function within the function’s body {}