Same confusion on 13/14 and 12/14...Big "?"


Why when I put parameter for the defined function, it won't work.
if I change it like
var happy = function() {
it works.

same question for
var nap = function(tired, bored){};

var programming = false;
var happy = function(programming) {
if (programming===!true) {
return true;
else {
return false;


Maybe its this problem:

PS: this was the answer to this post:

in case this isn't clear.


yeah thanks, I posted this new question before I see the answer. it drove me crazy.

Still not quite understand. in what cases we need to put the parameters, and in what cases we should not?


The most simple answer would be: "Use them when you need them".
If you write a function like "take out the trash" something that might not be fun, that takes a while but is always the same you just want to be able to trigger it when you need it without rewriting it, then you would not need a parameter. If you want a function to be interactive, to act on different inputs differently or at least expect any input at all than you would need parameters. So an example for a function that needs a parameter would be console.log as the output highly depends on what the user inputs and a function that does not take parameters would be Math.random as it always give you a random number between 0 and 1 whenever you ask for one.

Another example would be the exercise about the RPS game. There the compare function has parameters so you can rip it out of it's context feed it by your own values and it will still run, if you instead use the userChoice, computerChoice variables as global ones than you would need to copy them as well or write your own.