Best way to check aspect ratio?

Using this snippet to get the aspect ratios of the zappar screen what’s the best approach to making sure everything fits nicely no matter the size? I’m using primitive if else… to compare what aspect ratio value is returned and position/resize things accordingly but i feel like there could perhaps be a better solution? As the way i’ve done it, its’ like testing it on every mobile device on the planet which isn’t efficient.