Tell us what’s happening:
Your code so far
function smallestCommons(arr) {
let i = 0;
let range = [];
let result = 1;
for(let i = Math.min.apply(Math,arr); i <= Math.max.apply(Math, arr); i++){
range.push(i);
}
function lmc(q){
let temp =[];
if(q == 1){
return 1
}
for(let x = 1; x <= q; x++){
if(q%x == 0 && x !== 1){
temp.push(x)
}
}
return Math.min.apply(Math,temp)
}
while(i < range.length){
result *= lmc(range[i])
i++;
}
return result;
}
smallestCommons([2,10]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.44
.
Challenge: Smallest Common Multiple
Link to the challenge: