Call the function like this:
resultValue = myFunction(arg1, arg2. arg3);
Put a return statement in the function as the last statement:
function myFunction(valu1, valu2, valu3){
var theAnswer;
...
theAnswer = [I]your last calculation[/I];
return theAnswer;
};