Skip to content

Instantly share code, notes, and snippets.

@gtomitsuka
Created July 21, 2015 16:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtomitsuka/ee34a00b23da60bc6929 to your computer and use it in GitHub Desktop.
Save gtomitsuka/ee34a00b23da60bc6929 to your computer and use it in GitHub Desktop.
toLower(str) - Alternative to String.prototype.toLowerCase(), written for a Quora answer.
function toLower(str){
var result = '';
for (var i = 0, len = str.length; i < len; i++) {
var charAtLocation = str.charCodeAt(i);
if(charAtLocation > 64 && charAtLocation < 91) //ASCII for upper-case
result += String.fromCharCode(charAtLocation + 32);
else
result += str[i];
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment