저장을 습관화
프로그래머스 LV.0 문자열 붙여서 출력하기 본문
프로그래머스 LV.0 문자열 붙여서 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181946
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 문제 명
문자열 붙여서 출력하기
2. 문제 설명
두 개의 문자열 str1, str2가 공백으로 구분되어 입력으로 주어집니다.
입출력 예와 같이 str1과 str2을 이어서 출력하는 코드를 작성해 보세요.
3. 제한 사항
1 ≤ str1, str2의 길이 ≤ 10
4. 예시
입력 #1
apple pen |
출력 #1
applepen |
입력 #2
Hello World! |
출력 #2
HelloWorld! |
5. 기본 제공 코드
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];
});
6. 제출한 내 답
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 () {
console.log(`${input[0] + input[1]}`);
});
6-2. VSC에 작성한 내용
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(`${input[0] + input[1]}`);
});
7. 특이사항
없음
8. 다른 사람이 작성한 답
8-1.
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
}).on('line', function (line) {
const strArr = line.split(' ')
console.log(strArr.join(''))
})
8-2.
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 () {
console.log(input.join(''));
});
8-3.
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);
});
'코딩 테스트 > 프로그래머스 - 자바스크립트' 카테고리의 다른 글
프로그래머스 LV.0 홀짝 구분하기 (0) | 2023.09.08 |
---|---|
프로그래머스 LV.0 문자열 돌리기 (0) | 2023.09.08 |
프로그래머스 LV.0 덧셈식 출력하기 (0) | 2023.09.08 |
프로그래머스 LV.0 대소문자 바꿔서 출력하기 (0) | 2023.09.07 |
프로그래머스 LV.0 배열 원소의 길이 (0) | 2023.09.07 |