[Easy] 709. To Lower Case

문제

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

s 문자열이 주어졌을 때, 모든 대문자들을 소문자로 변환하여라.

 

예시

Example 1:

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

Example 2:

Input: s = "here"
Output: "here"

Example 3:

Input: s = "LOVELY"
Output: "lovely"

 

제약 조건

Constraints:

  • 1 <= s.length <= 100
  • s consists of printable ASCII characters.

 

해결 과정

자바스크립트 문자열 내장 메서드를 잘 알고 있다면 쉽게 해결할 수 있다.

모든 문자열을 소문자로 바꾸어주는 toLowerCase()를 이용해 바로 해결하였다.

 

해결 코드

/**
 * @param {string} s
 * @return {string}
 */
var toLowerCase = function(s) {
    return s.toLowerCase();
};