Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created January 5, 2012 13:42
Show Gist options
  • Select an option

  • Save hughfdjackson/1565311 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/1565311 to your computer and use it in GitHub Desktop.
Pattern matching
function int_actions(num){
return num == 1 ? "1"
: num == 2 ? "2"
: num == 3 ? "3"
: /*else*/ "NOT MATCHED"
}
console.log(int_actions(1))
console.log(int_actions(2))
console.log(int_actions(3))
console.log(int_actions(4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment