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:
@ -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*".*?"/));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user