Skip to content

Instantly share code, notes, and snippets.

@skytreader
Last active December 24, 2015 06:39
Show Gist options
  • Save skytreader/6758603 to your computer and use it in GitHub Desktop.
Save skytreader/6758603 to your computer and use it in GitHub Desktop.
My javascript utility functions.
/**
* 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