Unintended Solution to "Removing Whitespace" Challenge

Tell us what’s happening:
I’m not having a problem, but I think this is an unintended solution to the challenge. It passes all the tests but is semantically not what the challenge asks the student to do. I don’t know if the tests should be changed to account for this or if this doesn’t matter at all

Your code so far


let hello = "   Hello, World!  ";
let wsRegex = /\s{2,}/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Challenge: Remove Whitespace from Start and End

Link to the challenge:

It is a solution tailored specifically for the input given, for example if the platform were to test also for

" Hello, World!   "

The above regex would fail.
Perhaps the goal of the challenge was specifically not to be too strict with the checks and “edge” cases.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.