8 kyu
Sum Arrays
5,539 of 200,345richardhsu
Description:
Write a function that takes an array of numbers and returns the sum of the numbers. The numbers can be negative or non-integer. If the array does not contain any numbers then you should return 0.
Examples
Input: [1, 5.2, 4, 0, -1]
Output: 9.2
Input: []
Output: 0
Input: [-2.398]
Output: -2.398
Assumptions
- You can assume that you are only given numbers.
- You cannot assume the size of the array.
- You can assume that you do get an array and if the array is empty, return 0.
What We're Testing
We're testing basic loops and math operations. This is for beginners who are just learning loops and math operations.
Advanced users may find this extremely easy and can easily write this in one line.
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Aug 2, 2014 |
Published | Aug 2, 2014 |
Warriors Trained | 274769 |
Total Skips | 15984 |
Total Code Submissions | 362569 |
Total Times Completed | 200345 |
Ruby Completions | 5539 |
JavaScript Completions | 73437 |
Haskell Completions | 1469 |
CoffeeScript Completions | 119 |
Clojure Completions | 887 |
Python Completions | 71929 |
C Completions | 5108 |
C# Completions | 10722 |
PHP Completions | 4811 |
R Completions | 787 |
Elixir Completions | 477 |
Dart Completions | 1726 |
Crystal Completions | 54 |
NASM Completions | 95 |
C++ Completions | 11077 |
Julia Completions | 157 |
Racket Completions | 86 |
Factor Completions | 43 |
Java Completions | 16915 |
Lua Completions | 393 |
Total Stars | 884 |
% of votes with a positive feedback rating | 91% of 11492 |
Total "Very Satisfied" Votes | 9663 |
Total "Somewhat Satisfied" Votes | 1551 |
Total "Not Satisfied" Votes | 278 |