Just a quick example of using array.reduce to roll your own one-liner average calculation!
const average = (...nums) =>
nums.reduce((a, b) => a + b, 0) / nums.length;
console.log(average(1, 2, 3, 4));
// 2.5
Cheers!
Just a quick example of using array.reduce to roll your own one-liner average calculation!
const average = (...nums) =>
nums.reduce((a, b) => a + b, 0) / nums.length;
console.log(average(1, 2, 3, 4));
// 2.5
Cheers!
For further actions, you may consider blocking this person and/or reporting abuse
Sergi Mamedov -
Ikechukwu Kelechi Alexander -
Anil -
Omojola Tomiloba David -
Top comments (4)
This might be irrelevant to the topic. but how you made that cover photo with colorful tab design?
carbon.now.sh
The theme is Dracula!
thanks
Might be a stupid question, but if I don't want to put it as average calculation, it's still working right for any calculation?