• Re: Simple question on boolean function return value

    From Stefan Ram@21:1/5 to Janis Papanagnou on Fri Jan 13 15:09:54 2023
    Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
    return now.getDay()==5 && now.getDate==13;

    There is a pair of parentheses missing above.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to All on Fri Jan 13 15:56:49 2023
    Today I was surprised that some old code did not work as I'd have
    expected:

    function friday_13th (now)
    {
    return now.getDay()==5 && now.getDate==13;
    }

    That function returned 'false' and also putting parenthesis around
    the (sub-) expressions did not help. I had to use a local variable
    to make that work:

    function friday_13th (now)
    {
    var f13 = now.getDay()==5 && now.getDate()==13;
    return f13;
    }

    Can anyone explain that please?

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Stefan Ram on Fri Jan 13 16:23:15 2023
    On 13.01.2023 16:09, Stefan Ram wrote:
    Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
    return now.getDay()==5 && now.getDate==13;

    There is a pair of parentheses missing above.

    Argh! - I had been looking so long at that code that I obviously
    got "code-blind". - Thanks!

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From V V V V V V V V V V V V V V V V V V@21:1/5 to Janis on Sat Jan 28 09:05:57 2023
    P i c t u r e , ⠀⠀⠀p a r d o n ?





    On Friday, January 13, 2023 at 4:56:58 PM UTC+2, Janis wrote:
    Today I was surprised that some old code did not work as I'd have
    expected:

    function friday_13th (now)
    {
    return now.getDay()==5 && now.getDate==13;
    }

    That function returned 'false' and also putting parenthesis around
    the (sub-) expressions did not help. I had to use a local variable
    to make that work:

    function friday_13th (now)
    {
    var f13 = now.getDay()==5 && now.getDate()==13;
    return f13;
    }

    Can anyone explain that please?

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)