DEV Community

Cover image for #7DaysJS: Factorial and Average

#7DaysJS: Factorial and Average

Lautaro Lobo on November 29, 2019

Welcome to day 1 of 7 Days of JavaScript! A 7 days challenge to crack your head up into some simple but complex algorithms. Today we’ll work on wri...
Collapse
 
gustavosfq profile image
Gustavo Flores

const fact = (n) => n == 1 || n == 0 ? 1 : n * fact(n - 1);

const avg = (arr = []) => arr.length ? arr.reduce((a, b) => a + b) / arr.length : 0;

Collapse
 
jenc profile image
Jen Chan

Today I relearned what a factorial is! Thanks!