문자열 붙여서 출력하기

도비김·2024년 2월 22일
0
문제 설명

두 개의 문자열 str1, str2가 공백으로 구분되어 입력으로 주어집니다.
입출력 예와 같이 str1str2을 이어서 출력하는 코드를 작성해 보세요.


제한사항
  • 1 ≤ str1, str2의 길이 ≤ 10

입출력 예

입력 #1

apple pen

출력 #1

applepen

입력 #2

Hello World!

출력 #2

HelloWorld!

solution

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];

rl.on('line', function (line) {
    input = line.split(' ');
}).on('close', function () {
    str1 = input[0];
    str2 = input[1];
    console.log(str1+str2);
});

join('')으로 붙일수도 있지만 문제에서 str1 str2을 이용해 하라는거 같아서 그냥 +로 해줬다.

profile
To Infinity, and Beyond!

0개의 댓글