Created
January 3, 2018 13:20
-
-
Save authenticsebastian/592a56b6d1c64add36a643e45ab6a452 to your computer and use it in GitHub Desktop.
Calculate ratio of two numbers, with lower one being 1
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 getRatio = (w, h) => | |
( | |
h/w > w/h | |
? [w/w, h/w] | |
: [w/h, h/h] | |
) | |
.map( | |
(number) => Number(number.toFixed(2)) | |
) | |
.join(' : '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment