Tell us what’s happening:
“Smallest Common Multiple” challenge:
The following code will not pass test on the last test ([23, 18]), but node.js will! Please help!
Your code so far
function smallestCommons(arr) {
arr1 = arr.sort();
var nums = [];
for (var i = arr1[0]; i <= arr1[1]; i++) {
nums.push(i);
}
var nextNum = 1;
function lcmChecker(val) {
return nextNum % val == 0;
}
while (true) {
if (nums.every(lcmChecker)) {
return nextNum;
}
nextNum++;
}
}
smallestCommons([1,5]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/smallest-common-multiple