Skip to content

Commit 20cfd1c

Browse files
author
Jaskaran Singh
authored
Create to_lower_case.js
1 parent 3e43bce commit 20cfd1c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

to_lower_case.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string} str
3+
* @return {string}
4+
*/
5+
var toLowerCase = function(str) {
6+
let result = "";
7+
8+
for(let i = 0; i < str.length; i++) {
9+
if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
10+
let code = str.charCodeAt(i);
11+
let char = String.fromCharCode(code + 32);
12+
13+
result += char;
14+
} else
15+
result += str[i];
16+
}
17+
18+
return result;
19+
};

0 commit comments

Comments
 (0)