Skip to content

Instantly share code, notes, and snippets.

@Albert-IV
Created November 10, 2016 16:35
Show Gist options
  • Save Albert-IV/84b2d95358bc7c33cc909594d422e805 to your computer and use it in GitHub Desktop.
Save Albert-IV/84b2d95358bc7c33cc909594d422e805 to your computer and use it in GitHub Desktop.
getRandomStr = () ->
result = ''
validChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
# Since vanilla for loops are nearly impossible in CoffeeScript...
outputStr = [ '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ]
outputStr = outputStr
.map (s) ->
return validChars[Math.floor(Math.random() * validChars.length)]
.join('')
return outputStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment