--- id: 56533eb9ac21ba0edf2244a8 title: Storing Values with the Assignment Operator challengeType: 1 videoUrl: 'https://scrimba.com/c/cEanysE' --- ## Description
In JavaScript, you can store a value in a variable with the assignment operator. myVariable = 5; This assigns the Number value 5 to myVariable. Assignment always goes from right to left. Everything to the right of the = operator is resolved before the value is assigned to the variable to the left of the operator.
myVar = 5;
myNum = myVar;
This assigns 5 to myVar and then resolves myVar to 5 again and assigns it to myNum.
## Instructions
Assign the value 7 to variable a. Assign the contents of a to variable b.
## Tests
```yml tests: - text: Do not change code above the line testString: assert(/var a;/.test(code) && /var b = 2;/.test(code), 'Do not change code above the line'); - text: a should have a value of 7 testString: assert(typeof a === 'number' && a === 7, 'a should have a value of 7'); - text: b should have a value of 7 testString: assert(typeof b === 'number' && b === 7, 'b should have a value of 7'); - text: a should be assigned to b with = 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 (function(a,b){return "a = " + a + ", b = " + b;})(a,b); ```
## Solution
```js var a; var b = 2; a = 7; b = a; ```