Last active
December 24, 2015 06:39
-
-
Save skytreader/6758603 to your computer and use it in GitHub Desktop.
My javascript utility functions.
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
/** | |
* Set the character at a particular index in the given String. | |
* | |
* @param str | |
* The string to tweak. | |
* @param index | |
* The index where the replacement will take effect. | |
* @param chr | |
* The character to set in the given index. | |
*/ | |
function setCharAt(str,index,chr) { | |
if(index > str.length-1) return str; | |
return str.substr(0,index) + chr + str.substr(index+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment