Please remember to use spoiler tags when asking questions about a working solution!
Since your code works, I would look closely at the solutions and see where they are different.
-
Don’t store thing in an array if you only need them once. Building an array is expensive. Here you can just sum values as you find them.
-
Don’t compute more than you need to. A number only has unique divisors up to the square root, s you shouldnt check numbers past the square root for divisability.
Also note, Javascript isn’t a high performance language, so timings and performance comparison can be a bit tricky. For more, see the discussion here: