* 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>
		
			
				
	
	
		
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| id: 587d7db7367417b2b2512b9e
 | |
| title: Match Ending String Patterns
 | |
| challengeType: 1
 | |
| forumTopicId: 301352
 | |
| dashedName: match-ending-string-patterns
 | |
| ---
 | |
| 
 | |
| # --description--
 | |
| 
 | |
| In the last challenge, you learned to use the caret character to search for patterns at the beginning of strings. There is also a way to search for patterns at the end of strings.
 | |
| 
 | |
| You can search the end of strings using the dollar sign character `$` at the end of the regex.
 | |
| 
 | |
| ```js
 | |
| let theEnding = "This is a never ending story";
 | |
| let storyRegex = /story$/;
 | |
| storyRegex.test(theEnding);
 | |
| let noEnding = "Sometimes a story will have to end";
 | |
| storyRegex.test(noEnding);
 | |
| ```
 | |
| 
 | |
| The first `test` call would return `true`, while the second would return `false`.
 | |
| 
 | |
| # --instructions--
 | |
| 
 | |
| Use the anchor character (`$`) to match the string `caboose` at the end of the string `caboose`.
 | |
| 
 | |
| # --hints--
 | |
| 
 | |
| You should search for `caboose` with the dollar sign `$` anchor in your regex.
 | |
| 
 | |
| ```js
 | |
| assert(lastRegex.source == 'caboose$');
 | |
| ```
 | |
| 
 | |
| Your regex should not use any flags.
 | |
| 
 | |
| ```js
 | |
| assert(lastRegex.flags == '');
 | |
| ```
 | |
| 
 | |
| You should match `caboose` at the end of the string `The last car on a train is the caboose`
 | |
| 
 | |
| ```js
 | |
| assert(lastRegex.test('The last car on a train is the caboose'));
 | |
| ```
 | |
| 
 | |
| # --seed--
 | |
| 
 | |
| ## --seed-contents--
 | |
| 
 | |
| ```js
 | |
| let caboose = "The last car on a train is the caboose";
 | |
| let lastRegex = /change/; // Change this line
 | |
| let result = lastRegex.test(caboose);
 | |
| ```
 | |
| 
 | |
| # --solutions--
 | |
| 
 | |
| ```js
 | |
| let caboose = "The last car on a train is the caboose";
 | |
| let lastRegex = /caboose$/; // Change this line
 | |
| let result = lastRegex.test(caboose);
 | |
| ```
 |