13.대소문자 변환
function solution(s) {
  let answer = "";
  for (let x of s) {
    if (x === x.toUpperCase()) answer += x.toLowerCase();
    else answer += x.toUpperCase();
  }
  return answer;
}
let str = "StuDY";
console.log(solution(str));반응형
    
    
    
  'FRONT > JAVASCRIPT' 카테고리의 다른 글
| [Javascript] 알고리즘 기본 문제 - 가운데 문자 출력 (0) | 2022.03.26 | 
|---|---|
| [Javascript] 알고리즘 기본 문제 - 가장 긴 문자열 (0) | 2022.03.25 | 
| [Javascript] 알고리즘 기본 문제 - 대문자로 통일 (0) | 2022.03.25 | 
| [Javascript] 알고리즘 기본 문제 - 대문자 찾기 (0) | 2022.03.23 | 
| [Javascript] 알고리즘 기본 문제 - 문자 찾기 (0) | 2022.03.22 |