Explaination

Divide the problem up: you have an array that always has two numbers. You want to turn that into an array from smallest to largest. So given [5, 1], you want to turn that into [1,2,3,4,5]. Then you can find the common multiple. It has to be the largest number or a multiple of it. So in this case, check if every number divides evenly into 5. If it doesn't, check it divided into 5 + 5 (10). If it doesn't, check it divided into 10 + 5 and so on: as soon as you get a number that divides, immediately return; that's the solution.

This is an issue; there are ways to optimise (there will be various values you can ignore if you calculate things first), but for this level, it just needs to work. You'd do stuff like threading and parallelising the calculations in other languages; JS has a massive disadvantage if you need to do maths stuff (primes, factorising, cryptographic stuff etc, normally you'd use C or Julia or similar)

Credited by: Dan Couper - github.com/DanCouper