We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd20195 commit da0c162Copy full SHA for da0c162
juhee067/[week1]Array/remove_min_number.js
@@ -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