Skip to content

Instantly share code, notes, and snippets.

@scjody
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scjody/10949239 to your computer and use it in GitHub Desktop.
Save scjody/10949239 to your computer and use it in GitHub Desktop.
That moment when you realize that, despite its numerous warts, it's possible to love JavaScript. This straghtforward construct just saved me 80 lines of cut and pasted code.
var default_value = parseInt(details.default_value);
function bar_class(d) {
if (default_value >= d.x && default_value < d.x + d.dx) {
return "default";
} else if (median >= d.x && median < d.x + d.dx) {
return "median";
}
return "standard";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment