--- id: 56533eb9ac21ba0edf2244ac challengeType: 1 videoUrl: 'https://scrimba.com/c/ca8GLT9' forumTopicId: 18201 localeTitle: 数字递增 --- ## Description
使用++,我们可以很容易地对变量进行自增或者+1运算。 i++; 等效于 i = i + 1; 注意
i++;这种写法,省去了书写=符号的必要。
## Instructions
重写代码,使用++来对变量myVar进行自增操作。 提示
了解更多关于++运算符Arithmetic operators - Increment (++).
## Tests
```yml tests: - text: myVar应该等于88。 testString: assert(myVar === 88); - text: myVar = myVar + 1;语句应该被修改。 testString: assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*myVar\+\+;/.test(code)); - text: 使用++运算符。 testString: assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code)); - text: 不要修改注释上方的代码。 testString: assert(/var myVar = 87;/.test(code)); ```
## Challenge Seed
```js var myVar = 87; // Only change code below this line myVar = myVar + 1; ```
### After Test
```js (function(z){return 'myVar = ' + z;})(myVar); ```
## Solution
```js var myVar = 87; myVar++; ```