Skip to content

Instantly share code, notes, and snippets.

@hrosenbauer
Created March 23, 2014 16:41
Show Gist options
  • Select an option

  • Save hrosenbauer/9725754 to your computer and use it in GitHub Desktop.

Select an option

Save hrosenbauer/9725754 to your computer and use it in GitHub Desktop.
be more descriptive about numbers
function aLot(n, one, two, many) {
var s = n === 1 ? one : (n === 2 ? two : many);
return s.replace(/\{\}/g, n);
}
aLot(1, 'one link', 'two links', 'countless links ({})');
aLot(2, 'one link', 'two links', 'countless links ({})');
aLot(99, 'one link', 'two links', 'countless links ({})');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment