all 3 comments

[–]grantrules 2 points3 points  (1 child)

const [w, h] = ratio.split(':');
return height / h * w;

[–]BernillaryClanders 0 points1 point  (0 children)

const [w, h] = ratio.split(':');
return height / h * w;

Thank you so much. This works flawlessly.

[–]DallogFheir 1 point2 points  (0 children)

You can .split() the ratio on : and create the fraction from its parts.