fix(curriculum): getUserInput is not defined
This commit is contained in:
@ -23,9 +23,9 @@ Refactor the function <code>setGear</code> inside the object <code>bicycle</code
|
|||||||
```yml
|
```yml
|
||||||
tests:
|
tests:
|
||||||
- text: Traditional function expression was not used.
|
- text: Traditional function expression was not used.
|
||||||
testString: assert(!getUserInput('index').match(/function/),'Traditional <code>function</code> expression was not used.');
|
testString: getUserInput => assert(!getUserInput('index').match(/function/),'Traditional <code>function</code> expression was not used.');
|
||||||
- text: <code>setGear</code> is a declarative function.
|
- text: <code>setGear</code> is a declarative function.
|
||||||
testString: assert(typeof bicycle.setGear === 'function' && getUserInput('index').match(/setGear\s*\(.+\)\s*\{/), '<code>setGear</code> is a declarative function.');
|
testString: getUserInput => assert(typeof bicycle.setGear === 'function' && getUserInput('index').match(/setGear\s*\(.+\)\s*\{/), '<code>setGear</code> is a declarative function.');
|
||||||
- text: <code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.
|
- text: <code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.
|
||||||
testString: assert((new bicycle.setGear(48)).gear === 48, '<code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.');
|
testString: assert((new bicycle.setGear(48)).gear === 48, '<code>bicycle.setGear(48)</code> changes the <code>gear</code> value to 48.');
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ tests:
|
|||||||
const bicycle = {
|
const bicycle = {
|
||||||
gear: 2,
|
gear: 2,
|
||||||
setGear: function(newGear) {
|
setGear: function(newGear) {
|
||||||
"use strict";
|
|
||||||
this.gear = newGear;
|
this.gear = newGear;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -54,14 +53,19 @@ console.log(bicycle.gear);
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
<section id='solution'>
|
<section id='solution'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// solution required
|
const bicycle = {
|
||||||
|
gear: 2,
|
||||||
|
setGear(newGear) {
|
||||||
|
this.gear = newGear;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bicycle.setGear(3);
|
||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
Reference in New Issue
Block a user