javascript check if number is multiple of 3
var num num = prompt('Enter the number') if (num % 3 == 0) document.write('Multiple of 3') else document.write('Not a multiple of 3')
Here is what the above code is Doing:
1. We are asking the user to enter a number.
2. We are storing the number in a variable called num.
3. We are checking if the number is divisible by 3.
4. If the number is divisible by 3, we are printing “Multiple of 3”.
5. If the number is not divisible by 3, we are printing “Not a multiple of 3”.