Last active
September 13, 2017 19:17
-
-
Save kilmc/476ae72fd61d83589b2d0f13b0ee22a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 intersection = (arr1, arr2) => arr1.length > arr2.length | |
| ? arr1.filter(x => arr2.includes(x)) | |
| : arr2.filter(x => arr1.includes(x)) | |
| const getFactors = (number) => Array | |
| .from(Array(number), (_, i) => i) | |
| .filter(i => number % i === 0) | |
| const calculateRatio = ([width, height]) => { | |
| const gcf = Math.max(...intersection(getFactors(width),getFactors(height))) | |
| return [width/gcf,height/gcf] | |
| } | |
| const calculateRatioHeight = ([width, height]) => (height/width)*100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment