January 11 - Return Odd Elements from an Array in Ruby
In this exercise you'll learn how to select the odd elements from an array of integers and return the collection of odd items.
Guide Tasks
- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license
Already a Bottega Student? Sign In
Summary
Build a program that filters an array of integers, and returns the odd elements.
Exercise Description
The program should take in an array of integers and output a filtered array that only contains the odd integers.
Sample Input
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Sample Output
[1, 3, 5, 7, 9]
Real World Usage
Being able to filter a list of elements is a common requirement in Ruby programs. Additionally, this solution allows you to utilize a number of built in filtering mechanisms provided by the Ruby enumerable library.