Hi team,
I was trying to solve factorial number of my own logic and I get some weird result, below is my code please help me with this
function Fact(n){
var m = n;
//console.log(m) // 5 initially
if(m === 1){return 1}
for(var i=m; i>=1; i–){
m*=i-1;
//console.log(m); // I get 120 here
}
return m; // this return statement is always 0, I’m not getting 120
}
Fact(5);