Here is my Rock Paper Scissors project.
Dear @stuffundefined, unknowingly you helped me when I tried to use the ternary conditional instead of the IF or Switch statements…
I was using return inside of the truthy / falsy expressions, and now I know why I was getting errors.
Thanks!!!
same here.
Thank you @stuffundefined
!
Hi! I have just started learning JS and I have a question. In the “determineWinner” function how does computer defies “userChoice” and “computerChoice”? Because in the functions above these two aren’t defined or mentioned. Does it somehow takes it from “getComputerChoise” and "getUserChoise’ omitting “get”? I’m really confused about this part of code. Thanks in advance
That’s about the arguments and parameters of functions.
The userChoice
variable (in the playGame
function) is used as the userChoice
parameter in the getUserChoice
.
Here’s an example of the sequence of stuff that happens.
function addOne(n) {
return n + 1;
}
var x = 5;
var y = addOne(x);
console.log("y = " + y);
x
is 5
and x
is used as the first argument for calling the addOne
function
so the value contained in x
becomes the first parameter of the addOne
function, which is n
so n
is 5 during that function call.
The function returns n + 1
so the function returns 6
This result is put as variable y
Thank you so much for answering. Still a bit confused, but it’s getting clearer after your example.