Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers.
Return the answer as a number, not a string.
Examples:
([9, 3, '7', '3']) => 22
(['5', '0', 9, 3, 2, 1, '9', 6, 7]) => 42
(['3', 6, 6, 0, '5', 8, 5, '6', 2,'0']) => 41
*^You can assume that you will always recieved valid input
Language: Bash
Length: 23
Solution:
Save this to a file, make it executable with
chmod + <file>
, then pass it some arguments and query the exit code withecho $?
.The above is limited to a maximum sum of 255 because it uses
exit
, but it can be shortened, and allow for higher sum values, but the above is the safest method since you don't particularly want to be modifyingIFS
.Language: Bash
Length: 15
Solution:
Save this to a file, make it executable with
chmod +x <file>
, and then pass it some arguments.