The code for javascript to be divisible by five is "value %5==0". Divisibility by five can be understood as the remainder is 0 after dividing a value by 5; you can use the "%" operator to perform the remainder operation, and then use the "==" operator to determine whether the remainder is 0.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript is divisible by five
In javascript, to determine whether it is divisible by five, you can use %
and ==
operator.
Divisible by five, it can be understood as: after dividing a value by 5, the remainder is 0.
Therefore:
You can use the "%" operator to perform the remainder operation
Then use the "==" operator symbol to determine whether the remainder is 0
Implementation code:
var a=25; if(a%5==0){ console.log("值被5整除"); }else{ console.log("值不被5整除"); }
[Related recommendations: javascript video tutorial 、webfrontend】
The above is the detailed content of What is the code for javascript divisibility by five?. For more information, please follow other related articles on the PHP Chinese website!