매개변수에 .length를 사용하여 값을 구할 수 있다.
/**
* @param {string} str
*/
function getCharCount(str) {
return str.length
}
console.log(getCharCount("Sam")); // 3
console.log(getCharCount("Alex 123")); // 8
console.log(getCharCount("Charley is here")); // 15
대소문자로 변환할 때 사용하는 함수는 toUpperCase() 와 toLowerCase() 함수이다
eg) 소문자 변환 활용 방법
/**
*param {string} name
*/
function lowerName(name) {
return name.toLowerCase()
}
console.log(lowerName("Sam")); // "sam"
console.log(lowerName("ALEX")); // "alex" 입력하세요