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
63 lines
1.1 KiB
Markdown
63 lines
1.1 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244a8
|
|
title: Storing Values with the Assignment Operator
|
|
challengeType: 1
|
|
forumTopicId: 18310
|
|
dashedName: storing-values-with-the-assignment-operator
|
|
---
|
|
|
|
# --description--
|
|
|
|
In JavaScript, you can store a value in a variable with the <dfn>assignment</dfn> operator (`=`).
|
|
|
|
```js
|
|
myVariable = 5;
|
|
```
|
|
|
|
This assigns the `Number` value `5` to `myVariable`.
|
|
|
|
If there are any calculations to the right of the `=` operator, those are performed before the value is assigned to the variable on the left of the operator.
|
|
|
|
```js
|
|
var myVar;
|
|
myVar = 5;
|
|
```
|
|
|
|
First, this code creates a variable named `myVar`. Then, the code assigns `5` to `myVar`. Now, if `myVar` appears again in the code, the program will treat it as if it is `5`.
|
|
|
|
# --instructions--
|
|
|
|
Assign the value `7` to variable `a`.
|
|
|
|
# --hints--
|
|
|
|
You should not change code above the specified comment.
|
|
|
|
```js
|
|
assert(/var a;/.test(__helpers.removeJSComments(code)));
|
|
```
|
|
|
|
`a` should have a value of 7.
|
|
|
|
```js
|
|
assert(typeof a === 'number' && a === 7);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
// Setup
|
|
var a;
|
|
|
|
// Only change code below this line
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
var a;
|
|
a = 7;
|
|
```
|