Skip to Main Content

To Lower Case

Problem URL:To Lower Case

My Solution

JavaScript

/**
 * @param {string} str
 * @return {string}
 */

const toLowerCase = (str) => {
  let char_code = 0;
  let lower_case_arr = [];
  for (let i = 0; i < str.length; i++) {
    char_code = str.charCodeAt(i);
    if (char_code >= 65 && char_code <= 90) char_code += 32;
    lower_case_arr.push(char_code);
  }
  return String.fromCharCode(...lower_case_arr);
};

Let's Connect

Twitter GitHub LinkedIn