Skip to content

Instantly share code, notes, and snippets.

@secretgspot
Created September 26, 2019 04:56
Show Gist options
  • Save secretgspot/b3ff1c42f235460c2f1c37da7efd1a66 to your computer and use it in GitHub Desktop.
Save secretgspot/b3ff1c42f235460c2f1c37da7efd1a66 to your computer and use it in GitHub Desktop.
// Find screen resolution based on ratio
function findScreenHeight(width, ratio) {
const [widthRatio, heightRatio] = ratio.split(':')
const height = width / widthRatio * heightRatio
return width + 'x' + height
}
findScreenHeight(1280,"16:9"); // '1280x720'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment