Find the Largest Words in an Array in Ruby

1
1072

Learn how to build a method that returns the largest words in an array in a Ruby program.

Summary

Implement a method that finds the largest words in a Ruby array.

Exercise File

Code File

Exercise Description

Given a number and an array of strings, find the largest strings in an array.

Sample Input

Given an array of strings:

%w{a group of words that are variable length}

And a number of the largest items:

3

Expected Output

["variable", "length", "words"]

Real World Usage

This is a common skill when it comes to working with data collections. Additionally, if you follow a functional approach, you can learn how to leverage blocks to filter data.

Solution

Can be found on the solutions branch on github.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here