Skip to content

Instantly share code, notes, and snippets.

@tdreyno
Forked from jeremyckahn/equivs.txt
Created September 12, 2011 00:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdreyno/1210381 to your computer and use it in GitHub Desktop.
Save tdreyno/1210381 to your computer and use it in GitHub Desktop.
Equivalent JS and CoffeeScript functions?
getSpeedySignature: (ofString) ->
sum = 0
for i in [0..ofString.length]
sum += ofString.charCodeAt(i)
sum
@tdreyno
Copy link
Author

tdreyno commented Sep 12, 2011

Or double fancy (unreadable):

getSpeedySignature: (ofString) ->
  sum = 0
  sum += c.charCodeAt(0) for c in ofString.split('')
  sum

@jeremyckahn
Copy link

Both work great, much more straightforward than my initial approach. @TrevorBurnham had a good solution too: https://gist.github.com/1210378#comments

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