EASY WAY:
function recursive(a, b)
{
if(a > b)
{
return 0;
}
return a + recursive(a+1, b);
}
console.log(recursive(3,7));
HARD WAY: (EASY + EXPLANATION)
What is a recursion in a common programming language?
according to Wikipedia: Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration).
translated in everyday language a recursion is when you iterate n-times a function(in this case) and every time that the function call hisself wait for the result of the invoked function's instance.
The invoked functions's intance will invoke himself another time and wait for the result.
When this endless loop will stop?
When an instance will finally return a value, this happens typically with a check before the recursive call(see the easy way).
When a function will return a value all the knots will be loose and the first function that started the cycle will return the final value.
if you want to go deep or just my short explanation was not convincing i reccoment you to read this article: https://www.codecademy.com/en/forum_questions/5060c73fcfadd700020c8e54