Skip to content

Commit 00e2417

Browse files
committed
Is Divisible by X and Y.
1 parent 4a496e6 commit 00e2417

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

IsDivisibleByXandY.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Checking to see if a number n is divisible by x and y.
3+
*/
4+
5+
6+
7+
const isDivisible = (n, x, y) => {
8+
9+
const firstResult = n / x
10+
const nextResult = n / y
11+
12+
if(firstResult % 1 === 0 && nextResult % 1 === 0) {
13+
return true
14+
}
15+
else {
16+
return false
17+
}
18+
}
19+
20+
// prints true
21+
console.log(isDivisible(8, 2, 2))
22+
23+
// also:
24+
// return (n % x === 0 && n % y === 0) ? true : false

0 commit comments

Comments
 (0)