February 12 - Sum an Array of String Based Integers in Ruby
This guide examines an efficient process for summing an array filled with string based integers in Ruby.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

Summary

Implement a method that takes in an array of string based integers that returns the sum of all of the integer values.

Exercise Description

Given the following array of strings:

["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]

Build out a method that converts the string values to integers and then totals the integers.

Expected Output

string_sum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"])
# 210

Real World Usage

This exercise will test two important development components:

  • Converting a data collection to a different data type.
  • Performing calculations on a collection of values.

Test Cases

Code File