Re: FOR loop issue

71 views
Skip to first unread message

Jan Honza Odvarko

unread,
Aug 13, 2012, 7:29:01 AM8/13/12
to Firebug
The number "117" is not generated by the console.log statement.
It's the result of the whole evaluated expression (code).

It's a bit surprising that the code has actually a result value
(it's value of the 's' variable), but Firebug is right in this
case

Honza


On Aug 8, 10:57 am, Len Nguyen <len.nguyen...@gmail.com> wrote:
> Hi,
>
> There is issue with firebug when using Console to run this code:
>
> for(var i=2; i <= 100; i++){
>     var s = 1;
>     for(var j = 2; j <= i/2; j++){
>         if(i % j == 0) s += j;
>     }
>     if(i == s){
>        console.log(i);
>     }
>
> }
>
> It prints 6, 28 and 117. It should be only 6 and 28.
>
> Regards / Len
Reply all
Reply to author
Forward
0 new messages