Tell us what’s happening:
Hey, I’am stuck on Smallest Common Multiple. I got a sorted array, then got all necessary numbers from it and now I’m trying to check it for multiple ‘x’ it fails. Could you pls give me a hint on why is it happening?
Your code so far
var allNums = [];
var end = [];
arr = arr.sort();
for (var i=arr[0]; i<=arr[1]; i++) {
allNums.push(i);
}
allNums.forEach(function (elem, index){ //strange behaviour
for (var x=0; x<100;x++) {
if (elem%x === 0) {
end.push(x);
}
else end.push(false); //just for checks
}
});
return end;
}
smallestCommons([1,5]);```
**Your browser information:**
Your Browser User Agent is: ```Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36```.
**Link to the challenge:**
https://www.freecodecamp.org/challenges/smallest-common-multiple