[level 0] 문자열 돌리기

2025. 5. 18. 06:07·Daily Logs/Algorithm Practice

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];
    for(let char of str){
    console.log(char)};
});
  • 주요 문법 : for...of 문 사용
  • for...of 문은 반복 가능한 객체에서 소스로 제공되는 일련의 값에 대해 작동하는 루프를 실행합니다.
    반복 가능한 객체에는 Array, String, TypedArray, Map, Set, NodeList(및 기타 DOM 컬렉션)와 같은 내장된 인스턴스뿐만 아니라 인수 객체, 생성 함수에 의해 생성된 생성기, 사용자 정의 반복 항목 등이 포함됩니다.
const array1 = ["a", "b", "c"];
for (const element of array1) {  
console.log(element);  
}
// Expected output: "a"  
// Expected output: "b"  
// Expected output: "c"

링크:MDN
깃허브
프로그래머스

'Daily Logs > Algorithm Practice' 카테고리의 다른 글

[level 0] 문자열 겹쳐쓰기  (0) 2025.05.18
[level 0] 홀짝 구분하기  (0) 2025.05.18
[level 0] 문자열 붙여서 출력하기  (0) 2025.05.18
[level 0] 덧셈식 출력하기  (0) 2025.05.18
[level 0] 특수문자 출력하기  (1) 2025.05.18
'Daily Logs/Algorithm Practice' 카테고리의 다른 글
  • [level 0] 문자열 겹쳐쓰기
  • [level 0] 홀짝 구분하기
  • [level 0] 문자열 붙여서 출력하기
  • [level 0] 덧셈식 출력하기
Jcob.moon
Jcob.moon
반가워요~ 하루하루 꾸준히 코딩 작성하는 곳입니다 !!
  • Jcob.moon
    Pixelated Thoughts
    Jcob.moon
  • 전체
    오늘
    어제
    • HelloWorld (173) N
      • Daily Logs (122)
        • TIL (Today I Learned) (63)
        • Algorithm Practice (55)
        • Dev Book Notes (4)
      • Deep Dives (36) N
        • 문제 해결 (Troubleshooting) (3) N
        • CS Fundamentals (22) N
        • Career Prep (4)
        • Technical Notes (7)
      • Project Log (7)
      • Any (3)
      • Cooperation (4) N
        • Github (2) N
        • Conventions (1)
        • Git (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.3
Jcob.moon
[level 0] 문자열 돌리기
상단으로

티스토리툴바