Oliver Eyton-Williams bd68b70f3d
Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

1.5 KiB

id, title, challengeType, forumTopicId
id title challengeType forumTopicId
587d7dbb367417b2b2512bac Remove Whitespace from Start and End 1 301362

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.

Tests

tests:
  - text: <code>result</code> should equal to <code>"Hello, World!"</code>
    testString: assert(result == "Hello, World!");
  - text: Your solution should not use the <code>String.prototype.trim()</code> method.
    testString: assert(!code.match(/\.?[\s\S]*?trim/));
  - text: The <code>result</code> variable should not be set equal to a string.
    testString: assert(!code.match(/result\s*=\s*".*?"/));

Challenge Seed

let hello = "   Hello, World!  ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line

Solution

let hello = "   Hello, World!  ";
let wsRegex = /^(\s+)(.+[^\s])(\s+)$/;
let result = hello.replace(wsRegex, '$2');