fix: added white space checks including newlines to ensure pro… (#38166)

* fix: added white space checks including newlines to ensure proper validation of trim method

* fix: Addressing comments
This commit is contained in:
Hassaan Pasha
2020-02-12 11:47:54 +05:00
committed by GitHub
parent 3d1dcbea11
commit 0498e27902

View File

@ -13,7 +13,7 @@ Sometimes whitespace characters around strings are not wanted but are there. Typ
## Instructions ## Instructions
<section id='instructions'> <section id='instructions'>
Write a regex and use the appropriate string methods to remove whitespace at the beginning and end of strings. Write a regex and use the appropriate string methods to remove whitespace at the beginning and end of strings.
<strong>Note</strong><br>The <code>.trim()</code> method would work here, but you'll need to complete this challenge using regular expressions. <strong>Note:</strong> The <code>String.prototype.trim()</code> method would work here, but you'll need to complete this challenge using regular expressions.
</section> </section>
## Tests ## Tests
@ -23,8 +23,8 @@ Write a regex and use the appropriate string methods to remove whitespace at the
tests: tests:
- text: <code>result</code> should equal to <code>"Hello, World!"</code> - text: <code>result</code> should equal to <code>"Hello, World!"</code>
testString: assert(result == "Hello, World!"); testString: assert(result == "Hello, World!");
- text: You should not use the <code>.trim()</code> method. - text: Your solution should not use the <code>String.prototype.trim()</code> method.
testString: assert(!code.match(/\.trim\(.*?\)/)); testString: assert(!code.match(/\.trim\([\s\S]*?\)/));
- text: The <code>result</code> variable should not be set equal to a string. - text: The <code>result</code> variable should not be set equal to a string.
testString: assert(!code.match(/result\s*=\s*".*?"/)); testString: assert(!code.match(/result\s*=\s*".*?"/));