Skip to content

Commit

Permalink
가까운 수
Browse files Browse the repository at this point in the history
  • Loading branch information
dudwns committed May 1, 2023
1 parent a1c0390 commit d1c485a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Programmers/exam66.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function solution(array, n) {
const subArray = array.sort().map((v) => Math.abs(n - v));
return array[subArray.indexOf(Math.min(...subArray))];
}

0 comments on commit d1c485a

Please sign in to comment.