Tell us what’s happening:
It is giving the right answers but failing all the tests but the first one, if you could help me figure out why that would be great! thanks!
Your code so far
const smallestCommons = (a, b) => {
let max = Math.max(a, b);
let min = Math.min(a, b);
let array = [];
for(let i = min; i <= max; i++){
array.push(i);
};
return array.reduce((a, b) => {
while (true) {
if (max % a === 0 && max % b === 0) {
return max;
}
max++
}
});
};
console.log(smallestCommons(23, 18));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Implement a Range-Based LCM Calculator - Implement a Range-Based LCM Calculator