Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

56 lines
1.2 KiB
Markdown

---
id: 587d7dbb367417b2b2512bac
title: Remove Whitespace from Start and End
challengeType: 1
forumTopicId: 301362
dashedName: remove-whitespace-from-start-and-end
---
# --description--
Sometimes whitespace characters around strings are not wanted but are there. Typical processing of strings is to remove the whitespace at the start and end of it.
# --instructions--
Write a regex and use the appropriate string methods to remove whitespace at the beginning and end of strings.
**Note:** The `String.prototype.trim()` method would work here, but you'll need to complete this challenge using regular expressions.
# --hints--
`result` should equal to `"Hello, World!"`
```js
assert(result == 'Hello, World!');
```
Your solution should not use the `String.prototype.trim()` method.
```js
assert(!code.match(/\.?[\s\S]*?trim/));
```
The `result` variable should not be set equal to a string.
```js
assert(!code.match(/result\s*=\s*".*?"/));
```
# --seed--
## --seed-contents--
```js
let hello = " Hello, World! ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line
```
# --solutions--
```js
let hello = " Hello, World! ";
let wsRegex = /^(\s+)(.+[^\s])(\s+)$/;
let result = hello.replace(wsRegex, '$2');
```