Struggling with -Storing Values with the Assignment Operator

Struggling with -Storing Values with the Assignment Operator
0
#1

Tell us what’s happening:

Your code so far


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator/

0 Likes

#2

The challenge asks:

Assign the contents of a to variable b

Or in other word: b should have the same value as a.

This looks suspicious:

var a = b;

Also a and b are already declared in the setup, no need to re-declare them, just assign a new values to them.

hope it helps :slight_smile:

0 Likes

#3

Declare and assign gave me so many issues when I started… theres something I came up with that might help you…I’d make the declare thing super dramatic in my head.

//Setup
“I do declare!!! Theres an a in my code!!!”
var a;
“I do declare!!! Theres a b in my code!!!” "b, heres your assignment…hold this 2"
var b = 2;

So right now, a is just sitting pretty, merely existing. No need to dramatically introduce it to your code again with a declaration. Just assign it work to do.

So yeah, read the instructions again and take note of what variable you need to put to work, and what you are to assign it the job of holding onto.

0 Likes