I don't understand how boolean works.In the following example what is the necessity of the line "var check=false" and how does it work?/when should I use them?what if I write "var check=true" instead??
if(n%i===0 && n!=i)
please explain boolean a bit .I'm stuck here
The boolean datatype is a 1-bit datatype that can either be set to "true" or "false". It is sometimes referred to as a flag variable to check if a certain condition is true.
var check=false; sets a variable check to the condition false.
if() statements and
while() statements check a boolean expression to see if that code will run or not.
So, after you declare check, if you said
that code wouldn't run because check is false.
Hope this helps