Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Collections Ruby Arrays Adding Items to Arrays

Please Help

Challenge Task 2 of 2

Using the unshift method, add the string "celery" to the beginning of the array. Oops! It looks like Task 1 is no longer passing. Get Help Recheck work Go to task One array.rb

grocery_list = ["milk", "eggs", "bread"] grocery_list >> "carrots" array.unshift ("celery")

array.rb
grocery_list = ["milk", "eggs", "bread"]
grocery_list >> "carrots"
array.unshift ("celery")

2 Answers

Hi Lacie,

You are close to passing this challenge! When adding "carrots" to the array you need to use "<<". To pass the next step you need to specify which array you want to use the "Unshift" method on which in this case would be grocery_list

grocery_list = ["milk", "eggs", "bread"]
grocery_list << "carrots"
grocery_list.unshift("celery")

Thank you!