[fix] Test for Pass Arguments to Avoid External Dependence in a Function (#34522)

* feat: test works for => fns, added solution

* fix: moved solution
This commit is contained in:
Aditya
2018-12-04 17:20:19 +05:30
committed by Kristofer Koishigawa
parent 21a7e3ee56
commit 4145efc467

View File

@ -28,7 +28,7 @@ tests:
- text: Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.
testString: assert(fixedValue === 4, 'Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.');
- text: Your <code>incrementer</code> function should take a parameter.
testString: assert(code.match(/function\s+?incrementer\s*?\(.+?\)/g), 'Your <code>incrementer</code> function should take a parameter.');
testString: assert(incrementer.length === 1, 'Your <code>incrementer</code> function should take a parameter.');
- text: Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.
testString: assert(newValue === 5, 'Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.');
@ -66,6 +66,12 @@ console.log(fixedValue); // Should print 4
<section id='solution'>
```js
// solution required
// the global variable
var fixedValue = 4;
const incrementer = val => val + 1;
var newValue = incrementer(fixedValue); // Should equal 5
console.log(fixedValue); // Should print 4
```
</section>