This code works but I am still trying to fully understand recursion. So if I change this:

```
// Write a function to get the factorial of a number.
var factorial = function(int){
if(int === 0){
return 1;
} else {
int = int * factorial(int - 1);
return int;
}
};
factorial(6);
```

TO THIS:

```
// Write a function to get the factorial of a number.
var factorial = function(int){
if(int === 0){
console.log("Why does it log this twice? And where does the returned 1 go?");
return 1;
} else {
int = int * factorial(int - 1);
return int;
}
};
factorial(6);
```

Why does it log the console command twice? Why do we need to return 1 if we have already returned the factorial, in this case 720? If you change â€śreturn 1â€ť to â€śreturn 2â€ť int changes from 720 to 1440, so does â€śreturn 1â€ť actually mean â€śmultiply int by 1â€ť?

I could not find the section in the category list so here is a link to the section: https://www.codecademy.com/courses/javascript-lesson-205/0/1

review: factorials section is near the end.

Edit: Similarly, in the next section: â€śProtecting against errors and crashesâ€ť we write in a termination condition for the event that int is a negative number.

```
// Write a function to get the factorial of a number.
var factorial = function(int){
if(int === 0){
return 1;
} else if(int < 0){
alert("You chose a negative number");
return;
} else {
int = int * factorial(int - 1);
return int;
}
};
factorial(6);
```

It works for the lesson criteria, but it always alerts an error message, even if you are running the function on a positive number. How can this be right? Seems like its ignoring the conditional and just running the code each time.