프로그래머스(JavaScript)/Lv0

[프로그래머스 : 코딩 기초 트레이닝] Lv0.문자열 돌리기(JavaScript)

지미지민 2024. 3. 10. 15:20

 

 

 

💜 코드


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 i of str){
        console.log(i);
    }
});

 

 

 

💜 실행결과


 

 

💜 다른 사람의 풀이


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];
    [...str].forEach(c => console.log(c))
});