Last Updated: February 25, 2016
·
575
· alexindigo

Generate 1099 random english letters without custom functions in Javascript

Works only in Chrome/Nodejs. Safari and Firefox will give you only 17 characters. :)

Math.random()
  .toString(9)
  .slice(2)
  .split('')
  .map(Number)
  .map(Math.atan2.bind(Math, 90))
  .map(Math.pow.bind(Math, 17))
  .map(Math.ceil.bind(Math))
  .map(Array.prototype.reduce.bind([0], String.fromCharCode.bind(String)))
  .join(' ')
  ;

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside