Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- javascript
- 과제
- 코틀린
- input
- 장단점
- Redux
- 특징
- 프로그래머스
- backjun
- 항해99
- 장점
- 자바스크립트
- React
- 차이점
- 개념
- 의미
- 단점
- Promise
- 부트캠프
- 리액트
- programmers
- 코딩 기초 트레이닝
- 안드로이드
- Android
- 코딩기초트레이닝
- 비교
- 웹개발종합반
- 스파르타코딩클럽
- 종류
- 문법
Archives
COCO World
[JavaScript/자바스크립트] 프로그래머스 Level.0 - 대소문자 바꿔서 출력하기 본문
🐳 문제 설명
영어 알파벳으로 이루어진 문자열 str이 주어집니다. 각 알파벳을 대문자는 소문자로 소문자는 대문자로 변환해서 출력하는 코드를 작성해 보세요.
🐳 제한 조건
- 1 ≤ str의 길이 ≤ 20
🐳 입출력 예
입력 #1
aBcDeFg
출력 #1
AbCdEfG
🐳 작성 솔루션
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let input = [];
rl.on('line', function (line) {
input = [line];
}).on('close',function(){
str = input[0];
result = [];
const strValue = [...str]
strValue.map(a => {
if(a === a.toUpperCase()) {
result.push(a.toLowerCase());
}else {
result.push(a.toUpperCase());
}
})
console.log(result.join(''));
});