HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
프론트엔드 스쿨 교안(1기)
/
📝
(코테준비) 자료구조 및 알고리즘
/
✌
JS 100제 - 2권
/
🔥
문제56
/
✔️
답안
✔️

답안

const nationWidth = { 'korea': 220877, 'Rusia': 17098242, 'China': 9596961, 'France': 543965, 'Japan': 377915, 'England' : 242900, }; const w = nationWidth['korea']; delete nationWidth['korea']; const entry = Object.entries(nationWidth); const values = Object.values(nationWidth); //gap에 최댓값 저장 let gap = Math.max.apply(null, values); let item = []; for (let i in entry){ if (gap > Math.abs(entry[i][1] - w)){ gap = Math.abs(entry[i][1] - w); item = entry[i]; } } console.log(item[0], item[1] - w);