문제는 어렵지 않았다. 아스키 코드 활용은 헷갈렸다.
아스키
대문자 : 65 ~ 90
소문자 : 97~122
function solution(s){
return [...s].map(x => x.toUpperCase()).join("");
}
let str="ItisTimeToStudy";
console.log(solution(str));
<아스키 활용코드>
function solution(s){
return [...s].map(x => x.charCodeAt() >= 65 && x.charCodeAt() <= 90 ? x : x.toUpperCase() ).join("");
}
let str="ItisTimeToStudy";
console.log(solution(str));
'🗃️javascript > 코테 프레임 문제' 카테고리의 다른 글
5-1 두 배열 합치기 (0) | 2023.09.26 |
---|---|
2-3 가위 바위 보(24년)[reduce문 acc를 빈 배열로 초기화한 예시] (0) | 2023.09.21 |
1-11 대문자 찾기[문자열 != 배열 || 아스키 코드 출력 : charCodeAt()] (0) | 2023.09.20 |
1-10 문자 찾기(24년)[수정된 기존 배열 리턴: map, 기존 배열x : forEach] (0) | 2023.09.19 |
1-9 A를 # 으로(24년)[배열은 참조타입, 문자열은 원시타입] (0) | 2023.09.19 |