Scott Sauyet
3/11/2015 2:52:00 PM
jonas.thornvall@gmail.com wrote:
> for (i=0;i<key.length;i++) keyarr[i]=key.charCodeAt(i);
>
> This seem a bit primitive is there no other way to simply remap the
> characters from a full string into an array.
Well, you can turn a string into an array as follows:
key.split(''); // 'nyckel' => ['n', 'y', 'c', 'k', 'e', 'l']
Then you can use `Array.prototype.map` on the resulting array to transform
it into a new array.
Or, as Martin says, you can apply `map` directly to the string.
-- Scott