just-handlebars-helpers icon indicating copy to clipboard operation
just-handlebars-helpers copied to clipboard

Not actually a issue but request for adding another imp. maths helper function i.e Factorial of a Number

Open GunarajKhatri opened this issue 2 years ago • 3 comments

code:

const factorial=(num)=>{
if(num===0 || num===1){
return 1;
}
return num*factorial(num-1);
}
console.log(factorial(18)) //6402373705728000

GunarajKhatri avatar Apr 20 '22 12:04 GunarajKhatri

.

GunarajKhatri avatar May 03 '22 03:05 GunarajKhatri

@GunarajKhatri Sorry for the very late reply.

You can add this helper yourself here --> https://github.com/leapfrogtechnology/just-handlebars-helpers/blob/main/src/helpers/math.js and send a Pull Request.

Also, don't forget to add some tests here --> https://github.com/leapfrogtechnology/just-handlebars-helpers/blob/main/tests/helpers/math.spec.js

We can happily merge the PR if you send it over. Thank you. Unfortunately there are no active contributors in this repository that can help you right away.

mesaugat avatar Jul 19 '22 16:07 mesaugat

@mesaugat How do we tackle decimal and negative numbers though?

bitcoinBandit1234 avatar Mar 09 '23 10:03 bitcoinBandit1234