Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ternary style to javascript.md #56

Open
kevinbarabash opened this issue Apr 6, 2017 · 0 comments
Open

add ternary style to javascript.md #56

kevinbarabash opened this issue Apr 6, 2017 · 0 comments

Comments

@kevinbarabash
Copy link
Contributor

The preferred ternary style is the following:

  • if it can fit on a single line, put it on a single line, e.g. const color = selected ? 'green' : 'orange'
  • if it can't fit on a single line, put the ? and : at the start of each line, e.g.
const result = reallyVeryLengthConditional
    ? superLongComputationOfPositiveResult()
    : superLongComputationOfNegativeResult();

const style = selected
    ? {
        color: 'green',
        fontWeight: 'bold',
    }
    : {
        color: 'orange',
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant