Hi,
I think I solved this exercise but the last condition is still unchecked.
I used the console to check what it was being returned, and it returns the same as the requirement. So I am confused whether it’s a bug or am I missing something?
These are the screenshots:
This is my code:
function smallestCommons(arr) {
if (arr[0] < arr[1]){
var a = arr[0];
var b = arr[1];
} else{
var a = arr[1];
var b = arr[0];
}
var commonMultiple = 0;
for (var i = 1; commonMultiple === 0; i++){
if( i % a === 0 && i % b === 0){
commonMultiple = i;
for (var j = a + 1; j < b; j++){
if(commonMultiple % j != 0){
commonMultiple = 0;
j = b;
}
}
}
}
return commonMultiple;
}
smallestCommons([1,5]);