Skip to content

Instantly share code, notes, and snippets.

@authenticsebastian
Created January 3, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save authenticsebastian/592a56b6d1c64add36a643e45ab6a452 to your computer and use it in GitHub Desktop.
Save authenticsebastian/592a56b6d1c64add36a643e45ab6a452 to your computer and use it in GitHub Desktop.
Calculate ratio of two numbers, with lower one being 1
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