* 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>
		
			
				
	
	
		
			73 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						|
id: 587d7db3367417b2b2512b8f
 | 
						|
title: Match Literal Strings
 | 
						|
challengeType: 1
 | 
						|
forumTopicId: 301355
 | 
						|
dashedName: match-literal-strings
 | 
						|
---
 | 
						|
 | 
						|
# --description--
 | 
						|
 | 
						|
In the last challenge, you searched for the word `Hello` using the regular expression `/Hello/`. That regex searched for a literal match of the string `Hello`. Here's another example searching for a literal match of the string `Kevin`:
 | 
						|
 | 
						|
```js
 | 
						|
let testStr = "Hello, my name is Kevin.";
 | 
						|
let testRegex = /Kevin/;
 | 
						|
testRegex.test(testStr);
 | 
						|
```
 | 
						|
 | 
						|
This `test` call will return `true`.
 | 
						|
 | 
						|
Any other forms of `Kevin` will not match. For example, the regex `/Kevin/` will not match `kevin` or `KEVIN`.
 | 
						|
 | 
						|
```js
 | 
						|
let wrongRegex = /kevin/;
 | 
						|
wrongRegex.test(testStr);
 | 
						|
```
 | 
						|
 | 
						|
This `test` call will return `false`.
 | 
						|
 | 
						|
A future challenge will show how to match those other forms as well.
 | 
						|
 | 
						|
# --instructions--
 | 
						|
 | 
						|
Complete the regex `waldoRegex` to find `"Waldo"` in the string `waldoIsHiding` with a literal match.
 | 
						|
 | 
						|
# --hints--
 | 
						|
 | 
						|
Your regex `waldoRegex` should find the string `Waldo`
 | 
						|
 | 
						|
```js
 | 
						|
assert(waldoRegex.test(waldoIsHiding));
 | 
						|
```
 | 
						|
 | 
						|
Your regex `waldoRegex` should not search for anything else.
 | 
						|
 | 
						|
```js
 | 
						|
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
 | 
						|
```
 | 
						|
 | 
						|
You should perform a literal string match with your regex.
 | 
						|
 | 
						|
```js
 | 
						|
assert(!/\/.*\/i/.test(code));
 | 
						|
```
 | 
						|
 | 
						|
# --seed--
 | 
						|
 | 
						|
## --seed-contents--
 | 
						|
 | 
						|
```js
 | 
						|
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
 | 
						|
let waldoRegex = /search/; // Change this line
 | 
						|
let result = waldoRegex.test(waldoIsHiding);
 | 
						|
```
 | 
						|
 | 
						|
# --solutions--
 | 
						|
 | 
						|
```js
 | 
						|
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
 | 
						|
let waldoRegex = /Waldo/; // Change this line
 | 
						|
let result = waldoRegex.test(waldoIsHiding);
 | 
						|
```
 |