Jump to content

function parameter


hisoka

Recommended Posts

Perhaps this is what you're trying to do:

function sum () {  var c = 3 ;  var b = 2;  var a = c+b;  if(a==5) {    alert("good");  } else {    alert("wrong");  }}

Or this:

function sum(b, c) {    return b + c;}var a = sum(3, 2);if(a == 5) {    alert("good");} else {    alert("wrong");}
Link to comment
Share on other sites

Or maybe...

<!DOCTYPE html><html><body><script>function sum(total,b,c) { var a = c+b; alert((a==total) ? "good" : "wrong") return a;}alert(sum(4,3,2));alert(sum(5,3,2));alert(sum(6,3,2));</script></body></html>

Or even...

<!DOCTYPE html><html><body><script>window.onerror = function(a, b, c, d){alert('Javascript Error:n'+a+'nURL: '+b+'nLine: '+c+'  Column: '+d);return true;}</script><script>function math(guess,b,c,oper,mathf) { var ans = mathf(b,c); alert( b + oper + c + "=" + guess + " is " + ((guess==ans) ? "correct":"wrong") );}math(4,3,2,"+",function(x,y){return x+y;});math(5,3,2,"-",function(x,y){return x-y;});math(6,3,2,"/",function(x,y){return x/y;});</script></body></html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...