Stucked in Storing Values with the Assignment Operator

Tell us what’s happening:
Please I dont seem to be making progress with my attempts on this challenge…Please, I need help to move past this level.

Your code so far

// Setup
var a;
var b = 2;

// Only change code below this line
var a, b = 7;
var a = 7;
var b = 7;
a = b;

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0.

Link to the challenge:

The wording of the test is ambiguous. It wants you to assign the value already stored in the variable a to the variable b.

Your current code does this:

var a, b = 7; // redeclares `a` with the value `undefined` and `b` with the value `7`
var a = 7; // redeclares `a` with the value `7`
var b = 7;  // redeclares `b` with the value `7`
a = b; // assigns the value stored in `b` to `a`

Redeclaring variables with var is considered bad practice and will sometimes be rejected by the parser (e.g. if you use strict mode).

You only need to write two lines of code:

  • One that assigns the value 7 to a
  • One that assigns the new value of a (i.e. 7) to b.


I did this, but didnt go throught:
var a = 7;
var a, b = 7;
a = b;

am done. Thanks for the hint.
var a = 7;
var b = a;

1 Like