Skip to content

Commit da0c162

Browse files
committed
제일 작은 수 제거하기
/ 중급
1 parent fd20195 commit da0c162

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// 정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요.
2+
// 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요.
3+
// 예를들어 arr이 [4,3,2,1]인 경우는 [4,3,2]를 리턴 하고, [10]면 [-1]을 리턴 합니다.
4+
5+
function solution(arr) {
6+
if (arr.length <= 1) return [-1];
7+
const min = Math.min(...arr);
8+
return arr.filter((v) => v !== min);
9+
}

0 commit comments

Comments
 (0)