Why function return undefined. : This a simple code for factorial, I have written the function and it loops through giving right output but at the end, it goes undefined. I don't know why. 

    `function factorial(n){
        let value=1; 
        for(let i=1;i<=n;i++) 
         { value = i*value; console.log(value); }  
       }`