fix/update-es6-destructor-challenge: Added test (#35455)
* fix/update-es6-destructor-challenge: Added test - Added test incase during destructuring somebody pass and extra key * fix/update-es6-destructor-challenge: Fixed the test case per review comments -Cleaned up regex - Setup two cases one where additional assignment of variables before and then after - Did not put uppercase case CONSTANT checks because not related to question * fix: corrected tests
This commit is contained in:
		| @@ -19,7 +19,7 @@ You may read it as "get the field <code>x</code> and copy the value into <code>a | ||||
|  | ||||
| ## Instructions | ||||
| <section id='instructions'> | ||||
| Use destructuring to obtain the average temperature for tomorrow from the input object <code>avgTemperatures</code>, and assign value with key <code>tomorrow</code> to <code>tempOfTomorrow</code> in line. | ||||
| Use destructuring to obtain the average temperature for tomorrow from the input object <code>AVG_TEMPERATURES</code>, and assign value with key <code>tomorrow</code> to <code>tempOfTomorrow</code> in line. | ||||
| </section> | ||||
|  | ||||
| ## Tests | ||||
| @@ -28,9 +28,11 @@ Use destructuring to obtain the average temperature for tomorrow from the input | ||||
| ```yml | ||||
| tests: | ||||
|   - text: <code>getTempOfTmrw(AVG_TEMPERATURES)</code> should be <code>79</code> | ||||
|     testString: assert(getTempOfTmrw(AVG_TEMPERATURES) === 79, '<code>getTempOfTmrw(AVG_TEMPERATURES)</code> should be <code>79</code>'); | ||||
|     testString: assert(getTempOfTmrw(AVG_TEMPERATURES) === 79); | ||||
|   - text: destructuring with reassignment was used | ||||
|     testString: getUserInput => assert(getUserInput('index').match(/\{\s*tomorrow\s*:\s*tempOfTomorrow\s*}\s*=\s*avgTemperatures/g),'destructuring with reassignment was used'); | ||||
|     testString: getUserInput => assert(code.match(/{[\S\s]*\w+\s*:[\S\s]*\w+\s*}\s*=\s*(avgTemperatures|AVG_TEMPERATURES)/)); | ||||
|   - text: The key <code>tomorrow</code> was destructured from <code>AVG_TEMPERATURES</code> | ||||
|     testString: getUserInput => assert(code.match(/{[\S\s]*tomorrow\s*:\s*tempOfTomorrow[\S\s]*}\s*=\s*(avgTemperatures|AVG_TEMPERATURES)/));  | ||||
|  | ||||
| ``` | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user