why is it necessary to add return statement before ternary operator in recursive function to return function output?

```js
// This dose not work

    function rec(n) {
      n == 1 ? n : n + rec(n - 1);
    }

// This works as return statement is added before ternary operator
    function rec(n) {
      return n == 1 ? n : n + rec(n - 1);
    }

// This works
    function rec(n) {
      if (n == 1) return 1;
      return n + rec(n - 1);
    }
```