function isDivisible(n, x, y) {
let answer = n;
let optionOne = answer / x;
let optionTwo = answer / y;
if(optionOne === y && optionTwo === x){
return true;
}else{
return false;
}
}
I pass 3/4 tests for this problem:
I just don’t know what I could add so it can pass the last test. All help appreciated!
Thanks in advance!
Regards
Ma3_str0
because for example if we call the function with n = 18
, x = 6
, y = 9
first line you have let answer = n
so now answer
equals 18
then let optionOne = answer / x;
so it is 18 / 6
, so optionOne
is 3
with same thing, optionTwo
is 2
now you check
if(optionOne === y && optionTwo === x)
which results as false, so at the end your function returns false
the logic doesn’t seem sound.
you need to change approach.
how would you check logically and with maths? without writing the code, what steps would you do to manually check if that number is divisible by those numbers?
you may want to take a look at the %
operator instead