Tell us what’s happening:
To the best of my knowledge the following code fulfills all the requirements of this step:
The function removeSpecialChars
is defined.
It removes single quotes.
It removes double quotes.
It removes underscores.
It does not remove spaces.
I have of course run the code without the testStr
initialization and console.log()
.
I appreciate these sorts of steps/challenges that allow a degree of freedom and difficulty, but if you want me to use a specific method to achieve the intended goal, it should be specified. Forgive me if I am wrong.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
let testStr = `"'Testing _ all () sorts \ of / characters[]'"`
const removeSpecialChars = (string) => {
const regex = /[^_\W]+/g;
return string.match(regex).join(" ");
}
console.log(removeSpecialChars(testStr));
// Testing all sorts of characters
// User Editable Region
/* file: styles.css */
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