Learn Modern JavaScript Methods by Building Football Team Cards - Steps 18 - 21

Tell us what’s happening:

I have a question and it’s really bugging me.

Using examples:

year = worldCup.textContent
worldCup.textContent = year

Are they both the same thing or is it 2 different things in JS?

I don’t know if the course is just really particular on what order they want things to be, or if it actually matters

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region




// User Editable Region

Your browser information:

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

Challenge Information:

Learn Modern JavaScript Methods by Building Football Team Cards - Step 21

These mean completely different things.

I’m not sure I understand why they are different

Well, what does the = operator do?

To my understanding, on the first example it assigns the value of worldCup.TextContent to the varriable year.

But what I don’t understand is that worldCup is also a varriable and we’re just accessing the text of its element.

But won’t it be the same if I do it the other way as well?

Lets use shorter variable names for simplicity

a = b

vs

b = a

Would taking the contents inside of b and storing it inside of a do the exact same thing as taking the contents of a and sticking it inside of b? How could we test that idea?

Oh okay. I think I understand now

If we assume

a = "apple";
b = "banana";

Then

a = b;

would make both “a” and “b” have the value of “banana”

and vice versa would make them have the value of “apple”

Thanks for clearing that up. I should have gone to simple examples to clear that one up but at least I know now :joy:

2 Likes

Hey, experimenting with simpler examples helps me all the time, and I’ve got a job doing this stuff.

2 Likes