Help with Smallest Common Multiple and Infinite Loop

I am wondering why this code is returning an infinite loop…

function smallestCommons(arr) {
  var maxNum = Math.max.apply(null,arr);
  var minNum = Math.min.apply(null,arr);
  var rangeSeq = [];
  for (var i = minNum; i <= maxNum; i++) {
  var multiple = 0;
  var checkFunc = function(b) {
    return b === 0;
  var remain = {
    return multiple % a;
  do {
    multiple += multiple;
  while (remain.every(checkFunc) === false);
  return multiple;


Not seeing an infinite loop with your code. Your function does return zero for every test case though.

When multiple is 1, it returns a warning for an infinite loop. Also, why is it returning 0?

Put the following console.log statement right after the assignment to remain with the map:

  var remain = {
    return multiple % a;
  console.log(remain); // display the array of zeros here

remain is an array of zeros. Why? Because you start off with multiple = 0. Inside the map callback function you return multiple %strong text a for each number in rangeSeq. Zero mod any number greater than zero is 0. That is why remain is an array of zeros.

Which test specifically is warning of infinite loop?