Skip to content

Instantly share code, notes, and snippets.

@willwalker753
Created February 12, 2020 21:42
Show Gist options
  • Save willwalker753/77402a2c0c470a42c3356698e8d2407d to your computer and use it in GitHub Desktop.
Save willwalker753/77402a2c0c470a42c3356698e8d2407d to your computer and use it in GitHub Desktop.
Is divisible
function isDivisible(dividend, divisor) {
let rem = dividend % divisor;
let divisible = false;
if (rem === 0) {
divisible = true;
}
return divisible;
}
let dividend = 18;
let divisor = 3;
console.log(isDivisible(dividend, divisor));
function testIsDivisible() {
if (isDivisible(10, 2) && !isDivisible(11, 2)) {
console.log('SUCCESS: `isDivisible` is working');
} else {
console.log('FAILURE: `isDivisible` is not working');
}
}
testIsDivisible();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment