main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// function smallestCommons(arr) {
//   return arr;
// }


// smallestCommons([1,5]);


// smallestCommons([1, 5]) should return a number.
// smallestCommons([1, 5]) should return 60.
// smallestCommons([5, 1]) should return 60.
// smallestCommons([2, 10]) should return 2520.
// smallestCommons([1, 13]) should return 360360.
// smallestCommons([23, 18]) should return 6056820.
const factorsArray = [];
function factors(num) {


  for (let i = 1; i <= num; i++) {
    if (num % i === 0) factorsArray.push(i)
  }
}
// factors(8)
function commonDenominators(num1, num2) {
  factors(num1);
  factors(num2)

  return factorsArray

}
commonDenominators(4, 8)
Native Browser JavaScript