Tell us what’s happening:
I tried \W but it didn’t work.
I don’t want to pass the test with Hello, World! I need to do the “appropriate string methods” (pass the test with special characters).
Your code so far
let hello = " Hello, World! ";
let wsRegex = /\b\w{5}\W+\s\D+\b/; // Change this line
let result = hello.match(wsRegex); // Change this line
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0.
If you don’t remember all the string methods that freeCodeCamp has introduced so far (or if you want to see what else is available) you can see the list and their descriptions here.
If you look at the page for .match(), you’ll see that it returns an array or null. So your result will not be a string.
Your regular expression is a bit peculiar. The task is the remove whitespace from the beginning and end of a string. There are regex symbols for whitespace and for “beginning of the string” and “end of the string”.
We would need to see your new code to help you. The tool I linked should help as well.
Ro reiterate though, the point is not to write something that matches “Hello, World!” You can write code that will trim the whitespace off of any arbitrary string.
If you are interested in adding a new solution or hint you will need to create a new post in the Contributors section.
For contributions, please wrap your solution within :
[details]
```
code goes here...
```
[/details]
Also, provide all of the necessary code to pass the challenge.
Also, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor ( </> ) to add backticks around text.