Hello Fellow campers,
So after a dazzling 2 hours of thinking failing and thinking and and failing again, i was able to formulate a solution to solve the above challenge. After i decided to learn from freecodecamps solution and the solutions there were more confusing than mine. But solution 4 was simple and i tried to understand it but i just couldn’t. Could anyone please help me to with a simple explanation to this solution. Thanks a lot.
const smallestCommons = arr => {
let max = Math.max(...arr);
let min = Math.min(...arr);
let sol = max;
console.log(sol)
for (let i = max - 1; i >= min; i--) {
console.log(i)
if (sol % i) {
console.log(sol += max);
i = max;
}
}
return sol;
};