How to "pass in two functions as an argument"?


#1
 if (choice2 === "rock") {
        return("paper wins")
    }
    else {
        return("scissors wins")
    }
}
else if (choice1 === "scissors") {
    if (choice2 === "rock") {
        return("rock wins")
    }
    else {
        return("scissors")
    }
}

};

what after this??


#2

Could you post all of your code and explain in more detail what your problem is? When you say functions, do you instead mean statements in an argument, such as an if statement? Are you asking how to do this:

if (choice1 === 'rock' && choice2 === 'rock' ) {
    return('The result is a tie!');
}

Is this what you mean? To compare different arguments in an if statement:
And == &&
Or = ||
You can combine statements just as you would in math using parenthesis, PEMDAS doesn't necessarily apply instantly in javascript, however items enclosed in parenthesis are processed first. Think of parenthesis as a mini instantly called function that returns a value from the statements inside it.

if ((a*5) > 10 && (b/2) < 10) {
    // Some code
}

Or do you instead want to pass in a function as an argument into another function?

console.log(somefunction(), somefunction2());

To extract a value from a function use a return statement, it'll place a value of data into to the script where the function is placed, so if you wanted to pass a function into another one, it would have to return data, rather than console.log or just assigning it to some variable.


#3

For a list of operator priorities see this:
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
and this:
console.log(somefunction(), somefunction2());
are still function calls as you said yourself they are just values. You just even pass functions by their name to other functions which is extensively used in the jQuery track.