Skip to content

Instantly share code, notes, and snippets.

@gerardpaapu
Created January 15, 2010 01:20
Show Gist options
  • Save gerardpaapu/277693 to your computer and use it in GitHub Desktop.
Save gerardpaapu/277693 to your computer and use it in GitHub Desktop.
// Javascript
function triangle(a,b) {
if(a > 0 && b > 0 ) {
function sqroot(x) {
return (x > 0) ? Math.pow(x,.5) : 0;
}
return sqroot( a*a + b*b );
} else return 0;
}
// mozilla specific
function triangle(a,b) {
if(a > 0 && b > 0 ) {
function sqroot(x) (x > 0) ? Math.pow(x,.5) : 0;
return sqroot( a*a + b*b );
} else return 0;
}
// trimmed mozilla
function triangle(a,b) {
if (a < 0 || b < 0 ) return 0;
function sqroot(x) (x > 0) ? Math.pow(x,.5) : 0;
return sqroot( a*a + b*b );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment