Rest & Spread: Summary Calculator | Sololearn: Learn to code for FREE!


Rest & Spread: Summary Calculator

You are making a program to calculate the sum of any number of values. Complete the given function so that it takes as parameters as many numbers as needed and returns the sum. // I want to understand this, but no luck after 30 + minutes. Please help.

2/16/2022 1:15:17 AM


2 Answers

New Answer


In your code, 'rest' variable is already an array. No need to initialize it again. We just need to run a for loop over the rest array, add all the items and return the final sum. That's it. 👍


Morpheus ! I’ve been waiting to see you here. Thank you for that advice, and I will try it! 🙏