Last active
November 19, 2019 07:05
-
-
Save myogeshchavan97/ea912736e366f61dcaac6537cf30cce2 to your computer and use it in GitHub Desktop.
Get sum of numbers using rest operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addNumbers(...numbers) { | |
let sum = 0; | |
numbers.forEach(function(value) { | |
sum += value; | |
}); | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment