Leetcode 709 - To Lower Case

Note:

Question:

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Example:

1
2
Input: s = "Hello"
Output: "hello"

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* @param {string} s
* @return {string}
*/
var toLowerCase = function(s) {
s = s.split('');
for (let i = 0; i < s.length; i++) {
if (s[i].charCodeAt(0) <= 'Z'.charCodeAt(0)) {
s[i] = s[i].toLowerCase();
}
}
return s.join('');
};