function solution(arr) {
return arr.length === 1 ? [-1] : arr.filter(el => el > Math.min(...arr))
}
console.log(solution([4, 3, 2, 1]));
apply 메서드를 사용한 최소값 찾기
function solution(arr) {
if (arr.length === 1 ) {
return [-1]
}
const minValue = Math.min.apply(null, arr)
const index = arr.findIndex(value => value === minValue)
arr.splice(index, 1)
return arr
}
console.log(solution([4, 3, 2, 1]));