Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var num = [1, 2, 3, 4, 5]
- var sum = 0
- function total (num) { /** loop through array and get sum of elements */
- for (var i = 0; i < num.length; i++) {
- sum += parseInt(num[i])
- }
- return sum;
- }
Add Comment
Please, Sign In to add comment