Created
July 21, 2015 16:52
-
-
Save gtomitsuka/ee34a00b23da60bc6929 to your computer and use it in GitHub Desktop.
toLower(str) - Alternative to String.prototype.toLowerCase(), written for a Quora answer.
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
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