Congrats! You failed your first code challenge!

It should look something like this.We iterate through every instance of the Car class and return an array that contains all the cars that a particular Car_Owner may have..Since we are in our CarOwner class “self” is referring to an instance of our car owner class..MapNow we have to return the mechanic that services a vehicle of an instance of a car_owner..Every instance of a car has the car_owner and mechanic, we will once again be going through our Cars class to find the mechanic..Whats great is that we already have a method that returns an array of all cars for a specific car_owner..Let’s make our lives easier..We’re going to use .map to modify our array of cars to show the mechanics only..It should look like this:Here we are mapping on the cars method..Each instance of a car has the info of a mechanic..This is also a good time to use a ‘binding.pry’ to see what your car array is actually returning.While we are in the car array we are telling the method to only return the car’s mechanic for the instance of a particular owner..Our cars array is the perfect helper method for being able to isolate what objects or values we want to be returned in a new array..**Quick tip for remembering when to use .select or .map..Select will return an array based on a conditional statement using “==”.. More details

Leave a Reply