Project Euler Smallest Multiple w/ JavaScript Question 5 for Project Euler is finding the smallest multiple of 1 - 20. My solution is not even close to most of the solutions I've researched. Any feedback, good or bad, is greatly appreciated as I've been self teaching how to code on and off the past year and a half.

function smallestMultiple()
{
  var smallest = 0;
  var found = false;
  var i = 0;
  while(!found)
    {
      i++
      if(i % 11 === 0 &amp;&amp; i % 12 === 0 &amp;&amp; i % 13 === 0 &amp;&amp; i % 14 === 0 &amp;&amp; i % 15 === 0 &amp;&amp; i % 16 === 0 &amp;&amp; i % 17 === 0 &amp;&amp; i % 18 === 0 &amp;&amp; i % 19 === 0 &amp;&amp; i % 20 === 0)
        {
          smallest = i;
          found = true;
        }
    }
  return smallest;
}
Since the problem calls for a positive number evenly divisible by numbers from 1 to 20, I would overlook the fact that the function isn't reusable and it's strictly for this use case. But in real world programming, you will want to strive for reuse. Expanding the algorithm to do more than just 1-20 would be a good exercise.

The function name is misleading. The function is single-purpose but the name... is not. smallestMultiple doesn't even inform readers that it's simply just for the numbers 1-20. A name change will do.

I see you're putting opening braces in a new line and independently. I'm not really a fan of this formatting since it takes up too much space. I would suggest the collapsed "egyptian" brackets and 2-space indent because in JS, you easily run off to the right. You will realize this when you work with callbacks and nested functions.

while(...)
  {
    // stuff
  }

while(...){
  // stuff
}


Instead of a very long list of hard-coded conditions, consider using an array of factors and array.every. array.every executes a callback for each item in the array. If all items cause the callback to return true, array.every returns true and false if otherwise. This allows you to have a dynamic number of values to check against.

function smallestMultiple(){
  var factors = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
  var found = false;

  for(var number = 1; !found; number++)
    found = factors.every(factor =&gt; number % factor === 0);

  return number;
}


Now with the code a bit cleaner and the factors are not anymore hardcoded, you can now move factors as an argument to the function. This makes it accept any number of values. This solves the very first concern mentioned.

function smallestMultiple(factors){
  var found = false;

  for(var number = 1; !found; number++)
    found = factors.every(factor =&gt; number % factor === 0);

  return number;
}

smallestMultiple([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);


Taking it a bit further, instead of a loop, we can use recursion. Much shorter but blows away the stack when the numbers become huge.

function smallestMultiple(factors, number = 1){
  return factors.every(factor =&gt; number % factor === 0) ? number : smallestMultiple(factors, number + 1);
}

smallestMultiple([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);


Note that I am using ES6 syntax for the most part because it's convenient to write. However, browsers don't support all of the syntax yet. You can convert it to ES5 using transpilers like Buble or Babel.