Skip to content

Instantly share code, notes, and snippets.

@kylebakerio
Created February 23, 2015 23:24
Show Gist options
  • Save kylebakerio/05ee74c14d207b78fc4b to your computer and use it in GitHub Desktop.
Save kylebakerio/05ee74c14d207b78fc4b to your computer and use it in GitHub Desktop.
function lessOfTwo(a,b){
a < b ? a : b;
};
console.log(lessOfTwo(10,20));
@trrichard
Copy link

Background: Coding style is a contentious issue. I'll do my best to keep my comments to what I have observed the most people doing.

Comments:

  • Use spaces instead of tabs, it renders better in web browsers. It seems like lots of people do this.
  • Don't user the ternary operator, it is considered "difficult to read." The number of situations in which it can be appropriately used are so small that, in my opinion, we just shouldn't use it. I can expand on this more but it's better to do so over the phone. Use an "if" block instead.
  • Don't use single letter variable names. In this case its not terribly important because its so simple. But as you add more variables or have to come back and read your own code later it gets really important. Suggested names "first" and "second."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment