Created
April 24, 2020 22:53
-
-
Save Shavindra/9b589aa9378c3eeeebf4d40e896e6d11 to your computer and use it in GitHub Desktop.
Value closest to zero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortedTemps = temps.sort((a, b) => Math.abs(a) - Math.abs(b) || b - a); | |
const result = sortedTemps[0] || 0; | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment