Could someone help me with a codeacademy program? (Java, beginner level)
I keep receiving an error message: "SyntaxError: 'return' statement outside of function" For the following code: var userChoice = prompt("Do you choose rock, paper or scissors?"); var computerChoice = Math.random(); if(computerChoice<0.33) { return "rock"; } else if(0.34<computerChoice>0.66) { return "paper"; } else { return "scissors"; };
u sure this is java?
Yeah. I'm in the Java beginner course.
what is the name of ut function?
I don't have a function. Just two variable and an if/else is/else statement. Do I need a function?
wait ill run it myself and test it
So after some fiddling around, codeacademy wanted the variable computerChoice to change to rock paper or scisssors, not to just return the value like I coded. :( Oh well. Thanks for trying to help me!!! I really appreciate it! :)
np
just curious tho.. why are you var in java? because java uses primitive data types
using var
I'm not really the coding expert, I just follow how the website tells me to identify functions and variables with "var". Can I ask what "primitive data types" are?
Join our real-time social learning platform and learn together with your friends!