Either you were given a trick question, or you've misunderstood the problem.
You cannot write a function that does this in pure JavaScript (or, for that matter, almost any other language). The problem is that it has to return a number the last time it's called, and a function at all other times. This would be doable if you knew in advance how many times your function is going to be called, but if I understand your question correctly, then you don't know that in advance. You'd need to be able to foretell the future to know when the function would be called for the last time.
You could also do this in a language with macros that let you inspect the syntax of your code as it's being run. This would let you know how long the current chain of calls is, so you'd know when to return a number instead of a function. But JavaScript doesn't do this; in fact, most languages don't.
Is it possible that your interviewers were looking for an add() function that takes a variable number of arguments? That's much easier:
function add() {
return Array.prototype.reduce.call(
arguments,
function (sum, next) {
return sum + next;
},
0
);
}