Tell us what’s happening:
When I run this via node. This code works just fine, but it seems to fails when running the test. I have noticed this has happened with some other things as well. Is this due to a memory restriction?
Your code so far
function smallestCommons(arr) {
arr = arr.sort((a,b) => a - b)
let num=arr[0]
let complete = true
let i = 1
while(complete){
i++
num=arr[0]*i
complete = doIt(arr,num)
}
console.log(num)
return num;
}
function doIt(arr, num) {
let alpha=arr[0]
while(num%alpha==0 && alpha<=arr[1]){
alpha++
}
if (alpha>arr[1]){
return false
} else {
return true
}
}
smallestCommons([23, 18]);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.93 Safari/537.36 Vivaldi/2.8.1664.40
.
Link to the challenge: