function FirstFactorial(num) {
var rval=1;
for (var i = 2; i <= num; i++)rval *= i;
return rval;
}FirstFactorial(4);
Why does the above function--which computes the factorial of a given number--need no "do" brackets -> ie, "{ }", placed after its For statement in order for it to work? I thought after for(...) one always put "{...code to execute here...}".
However, when I tried adding the "{}"s to that For statement shown up above, the code returned the wrong answer of "2" instead of "24" as the result of "4*2*3*1" aka "FirstFactorial(4)". I'm puzzled. Please somebody help me understand when to include do brackets in functions, and when they're unnecessary?
Thank you in advance to whomever may help...