Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

factorize a number

function factorialize(num) {
  return num < 0 ? 1 :
    new Array(num)
      .fill(undefined)
      .reduce((product, _, index) => product * (index + 1), 1);
}
factorialize(5);
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #factorize #number
ADD COMMENT
Topic
Name
5+7 =