Game not working: getting [Function] as a result


Hi everyone,

I wrote the code. And at the end I coded console.log(compare) to get the outcome of the game printed. But it just prints [Function] and I get to go on to the next lesson. No error message or anything. I don't know where I went wrong in my code..


console.log(compare) is printing the type of compare which is a function. In order to call the function, just add () after it: console.log(compare()) - this will actually call the compare function and then will print in the console the result of that function.


@shadowmar this is correct but calling compare with empty () would assign undefined to choice1 and choice2 so better use compare(value, value) e.g. compare("rock","paper") or even better compare(userChoice,computerChoice).


Not if by definition compare doesn't take any arguments :wink: I haven't seen OP's code, that's why I'm not assuming anything and explaining the default case. It's more valuable to explain the problem, not the actual implementation.


Ok that could be the case, but the instructions make sure that the compare function should have parameters and therefore arguments so in most cases they are needed :wink: