Last active
August 29, 2015 13:56
-
-
Save alexanderjeurissen/9307617 to your computer and use it in GitHub Desktop.
A string prototype that returns an array of char codes for the given string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String::charCodes = -> | |
@split("").reduce (previousValue, currentValue, index, array) -> | |
array[index] = currentValue.charCodeAt 0 | |
array | |
, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.charCodes = function() { | |
return this.split('').reduce(function (previousValue, currentValue, index, array) { | |
array[index] = currentValue.charCodeAt(0); | |
return array; | |
},0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment