Challenge 2: Equivalent Objects

Check for the equivalent elements in the array.

Problem statement

Change your code so that it outputs the following table containing an equal number of rows and columns. The objects in the given array should be represented as labels of the first row and the first column of the table.

Fill each cell with the result that == returns for the row and column header objects against that cell.

Tip: Break into subtasks

  1. Write some code that collects an array of arrays or an array containing all rows. This is a rows array with many arrays, each of which holds six results (cells) for each comparison.

  2. Add the row label (the object’s representation) to the beginning of the row. If you don’t remember this from a previous lesson, search for “ruby array add to the beginning.”

  3. Make sure each cell is five characters wide (wide enough to hold all data and header labels).

  4. Join the cells in each row with the " | " string.

  5. Add the table headers row.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy