Hi all,
I am trying to work out how this solution works, but I’m a bit lost when if(curr % 2 !== 0) return false and how the code continues.
Please could someone explain it? Thank you.
Its easier to explain if I can compare it to the solution you wrote. Can you post that?
There is no return statement there? I’m not sure what you mean by ‘returns false’. The body of an if statement only runs if the condition is true, but then the code proceeds no matter if the condition was true or false.
This is pretty far into the curriculum for you to not understand how to use if. You may be going much to fast.
Hi,
Thanks for the reply.
Sorry. I shouldn’t use ‘return false’. I understand the if statement only runs if the condition is true. But how does the code proceed if the condition is false?
Thanks. I’ve just realised why I was stuck. I thought the code stop running when 2%2 !== 0 => false but it only affect result += curr , the code continues to run curr += prev;prev = curr - prev;