8/9 how do you call function?


:weary: I need instructions on how to call the function. Everything else works fine.


Hi @shineon3,

There are two ways that I know of in which you can make a function:

var _____ = function (parameters){}

function _____(parameters){}



Those are good ways for creating a function but for calling a function you would simply do:


remember that the parameters that you use when you call the function are the things that you actually want the computer to compare and not the "names" that you used as place holders when making the function


I called my function using
compare(computerChoice,userChoice); and it still will not accept.


did you try it as:


if so then you'll need to post all of your code so we can try to find where the problem is


I understand that this is how to solve a function and for me it works fine. But on the previous exercises, I was forced to create a separate variable and call my function from inside of that. Why the difference?


I tried this finally. It worked! It really worked! Thank you so much for your help.


At least here:

else if(choice1==="rock"){
        if (choice2==="scissors"){
            return"rock wins";}
            return"paper wins";}
// here should be a } for the rock else if.
else if(choice1==="paper"){

you're missing a } before the next else if to close the previous one.


I tried it with an extra } but it still doesn't work..
SyntaxError: Unexpected token else


and i could pass the previous exercise without this extra } so the problem should be somewhere at the end


i copy pasted my code and now it works, strange


Ok your formatting was a bit strange sry. The mistakes I've found were that you missed ending a string somewhere, something like "rock instead of"rock" and that there was an additional } at the end of your code.