Tell us what’s happening:
The FCC editor is telling me my solution doesn’t work for only the last example but it works in my Atom editor and the browser. I can’t work out why. Any help?
Your code so far
function smallestCommons(arr) {
arr = arr.sort(function(a, b) {
return a - b;
});
var scm = function (x) {
for (var j = arr[0]; j <= arr[1]; j++) {
if (x % j !== 0) return false;
}
return true;
};
var result = 0;
for (var i = arr[0]*arr[1]; i < Infinity; i++) {
if (scm(i)) {
result = i;
break;
}
}
return result;
}
smallestCommons([1,5]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/smallest-common-multiple