* chore(learn): audit basic algorithm scripting * chore(learn): audit basic data structures * chore(learn): audit basic javascript * chore(learn): audit debugging * chore(learn): audit es6 * chore(learn): audit functional programming * chore(learn): audit intermidate algorithms * chore(learn): audit js projects * chore(learn): audit object oriented programming * chore(learn): audit regex * fix(learn): remove stray . * fix(learn): string to code * fix(learn): missed some * fix(learn): clarify strings Based on Randy's feedback, clarifies string instances where quotes were removed in favour of back ticks. * fix: apply suggestions - thanks Randy! :) Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: non-suggestion comments * chore(learn): remove comments from codes Removes the comments from the description and instruction code blocks to ensure that all relevant information is translatable. * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: revert crowdin fix * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * chore: change voice * fix: Christopher Nolan * fix: expressions would evaluate * fix: will -> would * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: to work to push * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
		
			
				
	
	
		
			78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						|
id: 587d7db8367417b2b2512ba3
 | 
						|
title: Match Whitespace
 | 
						|
challengeType: 1
 | 
						|
forumTopicId: 301359
 | 
						|
dashedName: match-whitespace
 | 
						|
---
 | 
						|
 | 
						|
# --description--
 | 
						|
 | 
						|
The challenges so far have covered matching letters of the alphabet and numbers. You can also match the whitespace or spaces between letters.
 | 
						|
 | 
						|
You can search for whitespace using `\s`, which is a lowercase `s`. This pattern not only matches whitespace, but also carriage return, tab, form feed, and new line characters. You can think of it as similar to the character class `[ \r\t\f\n\v]`.
 | 
						|
 | 
						|
```js
 | 
						|
let whiteSpace = "Whitespace. Whitespace everywhere!"
 | 
						|
let spaceRegex = /\s/g;
 | 
						|
whiteSpace.match(spaceRegex);
 | 
						|
```
 | 
						|
 | 
						|
This `match` call would return `[" ", " "]`.
 | 
						|
# --instructions--
 | 
						|
 | 
						|
Change the regex `countWhiteSpace` to look for multiple whitespace characters in a string.
 | 
						|
 | 
						|
# --hints--
 | 
						|
 | 
						|
Your regex should use the global flag.
 | 
						|
 | 
						|
```js
 | 
						|
assert(countWhiteSpace.global);
 | 
						|
```
 | 
						|
 | 
						|
Your regex should use the shorthand character `\s` to match all whitespace characters.
 | 
						|
 | 
						|
```js
 | 
						|
assert(/\\s/.test(countWhiteSpace.source));
 | 
						|
```
 | 
						|
 | 
						|
Your regex should find eight spaces in the string `Men are from Mars and women are from Venus.`
 | 
						|
 | 
						|
```js
 | 
						|
assert(
 | 
						|
  'Men are from Mars and women are from Venus.'.match(countWhiteSpace).length ==
 | 
						|
    8
 | 
						|
);
 | 
						|
```
 | 
						|
 | 
						|
Your regex should find three spaces in the string `Space: the final frontier.`
 | 
						|
 | 
						|
```js
 | 
						|
assert('Space: the final frontier.'.match(countWhiteSpace).length == 3);
 | 
						|
```
 | 
						|
 | 
						|
Your regex should find no spaces in the string `MindYourPersonalSpace`
 | 
						|
 | 
						|
```js
 | 
						|
assert('MindYourPersonalSpace'.match(countWhiteSpace) == null);
 | 
						|
```
 | 
						|
 | 
						|
# --seed--
 | 
						|
 | 
						|
## --seed-contents--
 | 
						|
 | 
						|
```js
 | 
						|
let sample = "Whitespace is important in separating words";
 | 
						|
let countWhiteSpace = /change/; // Change this line
 | 
						|
let result = sample.match(countWhiteSpace);
 | 
						|
```
 | 
						|
 | 
						|
# --solutions--
 | 
						|
 | 
						|
```js
 | 
						|
let sample = "Whitespace is important in separating words";
 | 
						|
let countWhiteSpace = /\s/g;
 | 
						|
let result = sample.match(countWhiteSpace);
 | 
						|
```
 |