Created
December 23, 2021 07:54
-
-
Save see-why/eab41731d6f54bd8a2782683f587789d to your computer and use it in GitHub Desktop.
Between two sets HackerRank Challenge
This file contains 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
function getTotalX(a, b) { | |
// Write your code here | |
let start = Math.max(...a); | |
let end = Math.min(...b); | |
let count = 0; | |
for(let i = start; i <= end; i++){ | |
let arr_factors = a.filter((e) => i % e == 0); | |
let arr_multiples = b.filter((e) => e % i == 0); | |
if (arr_factors.length == a.length && arr_multiples.length == b.length) { | |
count++; | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment