Question: I am trying to do an exercise from here <https://www.w3resource.com/javascript-exercises/javascript-recursion-function-exercise-7.php>

I understand the solution, however, I am kind of curious why my program does not yield the same answer as above. The way I choose the return the function is slightly different, however, it yields a number instead of true or false.

```js
function checkeven(num) {
    if (num === 0) {
        return true;
    } else if (num === 1) {
        return false;
    } else {
        console.log(num);
        return num - checkEven(num - 2);
    }
}

console.log(checkeven(8));
console.log(checkeven(9));
```

Answer: 
your code had issue since you we trying to subtract from a boolean value , Due to which type corecion occurs as per the rules given under ecmascript guidlines.(<https://www.ecma-international.org/ecma-262/7.0/#sec-ordinary-and-exotic-objects-behaviours>) 

you can go with the following solution:

```
  (function fixthis() {
      function checkeven(num) {

          if (num === 0) {
              return true;
          } else if (num === 1) {
              return false;
          } else {

              let Tempnum = num - 2;
              if (checkeven(Tempnum)) {
                  return true;

              } else {
                  return false;
              }
          }
      }
      console.log(checkeven(8));
      console.log(checkeven(9));

  })()

```
You can do:

```js
odd = function(n) {if (n%2 == 0) {return true} else {return false;}}

console.log(odd(8));
console.log(odd(5));
```

or:

```js
checkeven = function(num) {
    if (num === 0) {
        return true;
    } else if (num === 1) {
        return false;
    } else {
        return checkeven(num - 2);
    }
}

console.log(checkeven(8));
console.log(checkeven(9));
```