I've written the following simple JavaScript code. But whenever I run it, it displays "Undefined" as a result.
Following is the code:
function naturalSum(num1,num2) {
var sumValue = 0;
for (i=0;i<1000;i++)
{
if (i%num1 === 0 || i%num2 === 0) {
sumValue += i ;
}
}
}
document.write(naturalSum(3,5));
I want to know why this is happening. When I'm not enclosing the code within the function, the code's working fine. Kindly help me on this.
returncall, or is that your problem