Skip to content

Instantly share code, notes, and snippets.

@joshnabbott
Last active July 18, 2019 17:46
Show Gist options
  • Save joshnabbott/07745a2ed7e3d744c529f9ad695ded3c to your computer and use it in GitHub Desktop.
Save joshnabbott/07745a2ed7e3d744c529f9ad695ded3c to your computer and use it in GitHub Desktop.
// Nested ternary
const sortConnectorsFunc = (a, b) =>
// eslint-disable-next-line no-nested-ternary
a.connectorName < b.connectorName ? -1 : a.connectorName > b.connectorName ? 1 : 0;
// Vs if statement
const sortConnectorsFunc = (a, b) => {
if (a.connectorName < b.connectorName) return -1;
if (a.connectorName > b.connectorName) return 1;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment