I’m meant to assign the value of Var a to Var B. I’ve tried it a number of different ways. been stuck here for 25 minutes and I just dont understand I guess.
Ive tried:
a = b;
var a = var b;
b = 7;
What am I doing wrong?
// Setup
var a;
a = 7;
var b;
// Only change code below this line
var a = var b;
// Setup
var a;
a = 7;
var b;
// Only change code below this line
a = b;
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Assigning the Value of One Variable to Another
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
the question instructs me to assign Var A’s value too Var B.
so I tried doing so which I’d have thought would be: Var a = var b;
That didn’t work.
I tried a = b; That also didnt work.
I tried b = 7; this also didnt work.
hm… you know in something like php, that’s close to how you would write it… but this is JavaScript, so let’s go around asking ourselfs, what is “var”?
Well “var” is a word that tells JavaScript that the following thing will be a variable and it should tell the memory to make some room for it and also remember the name. That’s it. Once done, JavaScript knows this is a variable.
It’s like preparing a chair and a nametag - once it’s prepared, you can give it to whatever value you want to hold it.
Next up is “=” and what does that do? It tells JavaScript to store whatever value is ON THE RIGHT into the variable on the left.
So if I want to get a “name” variable with “Tom”, I write var name = "Tom".
Now read the task and example again and try to understand what is happening there.
Unless theres also a lesson on freecodecamp regarding formatting I don’t really know what your talking about. I’m a novice. Don’t have money to take college courses or a bootcamp. Which is why I’m here. I apologize though. I struggle with bits and pieces of this. Theres a lot of rules to the code that arent readily included in the lessons.
I finally figured it out although now I’m not sure of Formating and dont want to post more code that will irritate people.