Skip to content

Commit 968c20e

Browse files
authored
Added isDivisble.js (TheAlgorithms#437)
* Added isDivisble.js * isDivisible.js is now on StandardJS style * isDivisible now have examples
1 parent 01de729 commit 968c20e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Maths/isDivisible.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Checks if a number is divisible by another number.
2+
3+
const isDivisible = (num1, num2) => {
4+
if (isNaN(num1) || isNaN(num2) || num1 == null || num2 == null) {
5+
return 'All parameters have to be numbers'
6+
}
7+
if (num2 === 0) {
8+
return 'Not possible to divide by zero'
9+
}
10+
return num1 % num2 === 0
11+
}
12+
13+
console.log(isDivisible(10, 5)) // returns true
14+
console.log(isDivisible(123498175, 5)) // returns true
15+
console.log(isDivisible(99, 5)) // returns false

0 commit comments

Comments
 (0)