1

Is there a more effective way of generating ascii values? I'm trying to emulate this same pattern in JavaScript that I've written in Bash.

Bash

read -ra chars <<< $(echo -e "$(printf '\\x%x ' {33..126})")

JS

var chars = [];
for(var chr = 33; chr < 126; chr++) {
  chars.push(String.fromCharCode(chr));
}
theGrayFox
  • 921
  • 1
  • 10
  • 22

1 Answers1

0

Since you want to generate a password from them, you might as well just put all the characters in a string, something like this: Generate random string/characters in JavaScript

Community
  • 1
  • 1
  • I'll check out the link. The whole point of generating the array was to have all of the characters and then shuffling them and finally calling join to return a string. – theGrayFox Jun 03 '14 at 22:24