1function smallestCommons(arr) {
2 var max = Math.max(...arr);
3 var min = Math.min(...arr);
4 var candidate = max;
5
6 var smallestCommon = function(low, high) {
7 // inner function to use 'high' variable
8 function scm(l, h) {
9 if (h % l === 0) {
10 return h;
11 } else {
12 return scm(l, h + high);
13 }
14 }
15 return scm(low, high);
16 };
17
18 for (var i = min; i <= max; i += 1) {
19 candidate = smallestCommon(i, candidate);
20 }
21
22 return candidate;
23}
24
25smallestCommons([5, 1]); // should return 60
26smallestCommons([1, 13]); // should return 360360
27smallestCommons([23, 18]); //should return 6056820
1function smallestCommons(arr) {
2 var multiple = [];
3 arr.sort(function(a, b){
4 return a - b;
5
6 });
7 var range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
8 multiple =range(arr[0], arr[1], 1)
9
10 let max = Math.max(...multiple)
11
12 const small = (current) => n % current === 0;
13 let n = max * (max - 1)
14 let common = false;
15 common = multiple.every(small)
16 while(common === false){
17 n++
18 common = multiple.every(small)
19 }
20
21 return n
22}
23smallestCommons([1,5]); //returns 60