I wrote
function factorial(n) {
if (n === 0) {
return 1;
}
return n * factorial(n - 1);
}
console.log(factorial(3));
the codes is calculate factorial.
But I wrote the code in jsfiddle and run, nothing happens. And I wrote html like
<script>
function factorial(n) {
・
・
console.log(factorial(3));
</script>
and when it is browsed in GoogleChrome,nothing shows in console.I want to see 6 in console.log.6 is calculated by 1*2*3. What is wrong in my codes?How should I fix this?