--- id: 56533eb9ac21ba0edf2244a8 title: Storing Values with the Assignment Operator challengeType: 1 videoUrl: '' localeTitle: 使用赋值运算符存储值 --- ## Description
在JavaScript中,您可以使用赋值运算符将值存储在变量中。 myVariable = 5;这将Number5分配给myVariable 。作业总是从右到左。在将值分配给运算符左侧的变量之前,将解析=运算符右侧的所有内容。
myVar = 5;
myNum = myVar;
这将为myVar分配5 ,然后再次将myVar解析为5并将其分配给myNum
## Instructions
将值7分配给变量a 。分配的内容a变量b
## Tests
```yml tests: - text: 不要更改行上方的代码 testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), "Do not change code above the line");' - text: a的值应为7 testString: 'assert(typeof a === "number" && a === 7, "a should have a value of 7");' - text: b的值应为7 testString: 'assert(typeof b === "number" && b === 7, "b should have a value of 7");' - text: a应分配给b = testString: 'assert(/b\s*=\s*a\s*;/g.test(code), "a should be assigned to b with =");' ```
## Challenge Seed
```js // Setup var a; var b = 2; // Only change code below this line ```
### Before Test
```js if (typeof a != 'undefined') { a = undefined; } if (typeof b != 'undefined') { b = undefined; } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```