How can I get one common number in each iteration for example :
2 ==> 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 36 ... 60
3 ==> 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60
4 ==> 8 12 16 20 24 28 32 36 40 44 48 52 56 60
I want to loop through 2,3,4 and pause the loop if we get the same number in all elements. Thank you in advance.
function smallestCommons(array) {
let arr = array.sort()
let newArr = [];
for(let i = arr[0]; i <= arr[1]; i++){
console.log('when i = ', i);
for(let j = i; j <= arr[1]; j+= i){
console.log(j)
}
}
return newArr;
}