Need help with the Variables Quiz

Hello
I’m new here ^^
I just started my first quiz in the core foundation and I don’t get why the answer the way it is

I’ll share screencaps, plz help me get this

first this one, why is his favorite cookbook, his own book and not the other option, especially after it’s written in the code after the statement “+ my book”

What does that mean?

sec one this

why is the value suddenly 3 when it was 4 once?
Isn’t it saying then that 3=4?
I don’t get what it’s trying to do there?

it was 4, but then at the last line:

numSides = triangle

we update the variable (numsides) with the value stored in triangle variable.

Hello!

What is the statement (3rd line)? It is a string (a text inside the ‘’) + variable.

statement = My favorite cookbook is + X

In the first line we can see that X = another string ( myCookbook = ‘The Joy of Cooking’)

So the statement is the sum of both strings.

Is it clear?

Hello!

There is a difference between = and ===

We we use = we are passing a value to a variable. When we use === we comparing values.

So, in Line 2 we are saying that numSides has now a value of 4

In Line 3 we are saying that triangle has now a value of 3

In Line 4 we are saying that numSides has now the value of triangle (that is 3)

We can say that numSides === 3 now!

Hope I helped! :v:t2:

1 Like

Thank you :slight_smile:
You did.

1 Like

All the options are represented like strings though?

it said, given the value of “myCookbook, (which I’m guessing by the options is ) the joy of cooking”
What is the value of statement? And next to statement you have = ‘my favorite cookbook is’ + myCookbook
which then I guessed that it means the sentence was incomplete and I’m supposed to finished what’s after (is) and before (+ myCookbook )

But since + is there and after it, mycookbook, doesn’t it mean the answer should be ‘how to cook everything’ instead?

I don’t get it

The orange are variables. They are receiving strings (the yellow text) as values.

So, myCookbook receives the string ‘The Joy of Cooking’ (for example A = 1)
and yourCookbook receives the string ‘How to Cook Everything’ (for example B = 2)

the statement is a new variable. Let’s split it in two:

First, statement receives 'My favorite cookbook is ’ (for example C = 3)

And now we are adding another variable to the statement: 'My favorite cookbook is ’ + myCookbook (for example C = 3 + A)

What is the value of myCookbook? It is ‘The Joy of Cooking’ (for example A = 1)

So statement = 'My favorite cookbook is ’ + ‘The Joy of Cooking’ (for example C = 3 + 1)

The sum of 2 strings is a new big string.

So: statement = ‘My favorite cookbook is The Joy of Cooking’ (for example C = 4)