diff --git a/docs/archive.html b/docs/archive.html index 73dc1a481..0d57c8d42 100644 --- a/docs/archive.html +++ b/docs/archive.html @@ -277,4 +277,6 @@ window.speechSynthesis.speak(msg); };
speechSynthesis('Hello, World'); // // plays the message +
Squares each number in an array and then sums the results together.
Use Array.prototype.reduce() in combination with Math.pow() to iterate over numbers and sum their squares into an accumulator.
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); +
squareSum(1, 2, 2); // 9