Thank you for your reply! I’m so glad to hear you enjoyed reading the links and that you have a better understanding about returns and console logs.
I was really enjoying coding for the first time doing the functions as sad as that sounds lol
I don’t think that’s sad at all! I’m just learning too, and I think going ahead of the lessons on your own sounds like a great approach to learning.
I used the === operator to make choice1 equal to userChoice and choice2 equal to computerChoice inside the ‘compare’ function
Perhaps I am misunderstanding but
=== is for comparison; it will compare one value to another and see if they are equal. (
== does this, sort of, too, but if I understand correctly the problem with this is that if the two values are different types, e.g. a string and a number, one will be forced to become the same type as the other to sometimes unpredictable results, and is therefore best avoided). When you see
=== please imagine a balance/scale; rather than “equals to” think “are these equal?”
= is the assignment operator and makes “choice1 equal to userChoice” etc. as you describe above. Having said this, may I suggest you reexamine the first two lines of your function?
However if you recall variables from algebra class, lets say x = 2. The value of x is 2, and “x”, the variable, acts as a pointer that says, “Hey, when you see me, think ‘2’!”
Similarly, when we assign
choice1 we are saying that
choice1 points* to
userChoice, as a variable itself, should also point to a value (in this case I believe they are both
undefined, unless you uncommented the first part of the program).
Can you tell me where in the program we assign a value to
userChoice? (Including the commented code in your answer is ok.) Similarly, where do we assign a value to
If the primitive versus reference type distinction is new to you, just try to keep the variable contents in mind. Variables hold the actual values of primitive types, but they hold only references to the values of reference types.