Skip to content

Instantly share code, notes, and snippets.

@NobukazuHanada
Created April 26, 2014 14:14
Show Gist options
  • Save NobukazuHanada/11321120 to your computer and use it in GitHub Desktop.
Save NobukazuHanada/11321120 to your computer and use it in GitHub Desktop.
function cond(){
for(var i in arguments ){
if( arguments[i][0] ){
arguments[i][1]();
break;
}
}
}
var x = -1;
cond(
[x > 0, function(){ console.log(x + " is positive"); }],
[x === 0, function(){ console.log (x + " is zero"); } ],
[x < 0, function(){ console.log(x + " is negative"); }]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment