Eloquent JavaScript 2nd Edition recursion exercise solution -


I tried to solve the recurring practice of online book:

Here's the question:

We have seen that% (the remaining operator) can be used to test whether this number is used to check a number or weird using% 2 or not that it is divisible There is a positive way from two to the fact that a (positive, complete) number is too odd:

  • There is also zero.
  • One is strange.
  • li>
  • For any other number, its tolerance is similar to N-2.

    Define a recurring function according to this description. Function should accept a number parameter and return a boolean.

    Check it at 50 and 75. See how it behaves at 1. Why do I do this? Can you think of a way to fix it?

    Here's what I have tried and this works:

      function isEven (number) {if (number == 0) {back true; } And {return (-member% 2 == 0)? right wrong; } Returns also (number-2); } Console.log (isEven (-1));   

    But, this seems a wrong answer because I understand that the author wants me to use 2. I am thinking that this is the right answer or if it is wrong then someone can tell me in the right direction.

    I think you are being confused because of this reason, because you can not understand that How recursion works. The reason for this is that N2 is taking this number and decreasing it 2 until it is zero or one. So giving us a true or false one.

    Hope to help read about how the process of recycling works.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -