Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

78 lines
1.2 KiB
Markdown

---
id: 56533eb9ac21ba0edf2244ad
title: Decrement a Number with JavaScript
challengeType: 1
forumTopicId: 17558
dashedName: decrement-a-number-with-javascript
---
# --description--
You can easily <dfn>decrement</dfn> or decrease a variable by one with the `--` operator.
```js
i--;
```
is the equivalent of
```js
i = i - 1;
```
**Note:** The entire line becomes `i--;`, eliminating the need for the equal sign.
# --instructions--
Change the code to use the `--` operator on `myVar`.
# --hints--
`myVar` should equal `10`.
```js
assert(myVar === 10);
```
`myVar = myVar - 1;` should be changed.
```js
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
```
You should not assign `myVar` with `10`.
```js
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*10.*?;?/));
```
You should use the `--` operator on `myVar`.
```js
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(__helpers.removeJSComments(code)));
```
You should not change code above the specified comment.
```js
assert(/let myVar = 11;/.test(__helpers.removeJSComments(code)));
```
# --seed--
## --seed-contents--
```js
let myVar = 11;
// Only change code below this line
myVar = myVar - 1;
```
# --solutions--
```js
let myVar = 11;
myVar--;
```