Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
Example 1:
Input: "Hello"
Output: "hello"
Example 2:
Input: "here"
Output: "here"
Example 3:
Input: "LOVELY"
Output: "lovely"
//處理一
var toLowerCase = (str) => str.toLowerCase()
//處理二
var toLowerCase = function(str) {
let result = '';
let charCode;
str.split('').forEach(i => {
charCode = i.charCodeAt(0);
if(charCode >= 65 && charCode <= 90) charCode += 32;
result += String.fromCharCode(charCode)
})
return result;
}