저장을 습관화
프로그래머스 LV.0 카운트 다운 본문
프로그래머스 LV.0 카운트 다운
https://school.programmers.co.kr/learn/courses/30/lessons/181899
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 문제 명
카운트 다운
2. 문제 설명
정수 start_num와 end_num가 주어질 때, start_num에서 end_num까지 1씩 감소하는 수들을 차례로 담은 리스트를 return하도록 solution 함수를 완성해주세요.
3. 제한 사항
- 0 ≤ end_num ≤ start_num ≤ 50
4. 예시
start_num | end_num | result |
10 | 3 | [10, 9, 8, 7, 6, 5, 4, 3] |
5. 기본 제공 코드
function solution(start, end_num) {
var answer = [];
return answer;
}
6. 제출한 내 답
const solution = (start, end) => {
let answer = [];
for (i = start; i >= end; i--) answer.push(i);
return answer;
};
6-2. VSC에 작성한 내용
const solution = (start, end) => {
let answer = [];
for (i = start; i >= end; i--) answer.push(i);
return answer;
};
// 테스트
console.log(solution(10, 3));
// console.log(solution(" programmers "));
7. 특이사항
없음
8. 다른 사람이 작성한 답
8-1.
const solution = (start, end) => Array(start-end+1).fill(start).map((v,i)=>v-i);
'코딩 테스트 > 프로그래머스 - 자바스크립트' 카테고리의 다른 글
프로그래머스 LV.0 홀수 vs 짝수 (0) | 2023.09.16 |
---|---|
프로그래머스 LV.0 0 떼기 (0) | 2023.09.16 |
프로그래머스 LV.0 공백으로 구분하기 2 (0) | 2023.09.16 |
프로그래머스 LV.0 공백으로 구분하기 1 (0) | 2023.09.16 |
프로그래머스 LV.0 문자열 정수의 합 (0) | 2023.09.16 |