How to Solve Euler 1 in JavaScript

The Euler 1 problem is fairly simple to solve. Most people intuitively know how to do it. Here is how I would do it in JavaScript.

From left to right we do:

  • create an array of 1000 elements
  • insert the index of each element as it’s value (effectively giving us a list from 1 to 1000
  • reduce that array so that each value that are a multiple of either 3, 5 or both is added to running sum