DEV Community

Cover image for #7DaysJS: Factorial and Average
Lautaro Lobo
Lautaro Lobo

Posted on • Originally published at lautarolobo.xyz on

8 2

#7DaysJS: Factorial and Average

Liquid syntax error: 'raw' tag was never closed

Top comments (2)

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!

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay