toUpperCase()
메서드를 통해 문자열을 대문자로 변환할 수 있다.
const str = "Good Morning, Yoonsun";
const upperCaseStr = str.toUpperCase();
console.log(upperCaseStr) // GOOD MORNING, YOONSUN
toLowerCase()
메서드를 활용하자!
const str = "Good Morning, Yoonsun";
const lowerCaseStr = str.toLowerCase();
console.log(lowerCaseStr) // good morning, yoonsun
const str = "Good Morning, Yoonsun";
const upperCaseStr = str.toUpperCase();
const lowerCaseStr = str.toLowerCase();
// 대문자인지 확인
if (str === upperCaseStr) {
console.log("대문자다!");
}
// 소문자인지 확인
if (str === lowerCaseStr) {
console.log("소문자다!");
}