Hi Friends đź‘‹,

Welcome To Infinitbility! âť¤ď¸Ź

To check if a number is divisible by another number, use the remainder ( % ) operator if get `0` means the number is divisible else not.

Note: Here, another number is any number like 3, 4, 5, 6, 7, 8, etc.

Today, Iâ€™m going to show How do I check if a number is divisible by another number in javascript, here I will use the modulo ( % ) operator and `if... else` statements to check if a number is divisible by another number or not.

Letâ€™s start the todayâ€™s tutorial How do you check if a number is divisible by another number in javascript?

In the following example, we are going to do the number is a divisible 3 or not.

If the input number is divisible by `3` we will log `input number divisible` else `input number not divisible`.

letâ€™s write the code.

``````const inputNum = 15;

if (inputNum % 3 == 0) {
console.log('âś… input number divisible');
} else {
console.log('â›”ď¸Ź input number not divisible');
}
``````

In the above program, we have use `15` as input number, after that we check itâ€™s divisible by `3` or not.

letâ€™s check the output.