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 trialFabian Pijpers
Courses Plus Student 41,372 PointsI HAVE NO IDEA HOW TO GET SOMETHING CHAR GREATER THAN CHAR.LENGTH > 4
I HAVE NO IDEA HOW THESE HAVE TO BE GREATER THAN CHAR LENGTH 4
array = ["Tree", "House"]
house [] = array.select { |item| item > char.length == 4 }
3 Answers
Jeremiah Shafer
12,388 PointsI think you're overthinking the select
method. There's also a typo. Here's how I fixed it:
array = ["Tree", "House"]
array.each { |item| item.chars.length > 4 }
datavxn
16,180 PointsYou're welcome! Looks like it changed formatting when I posted. "House" starts on a different line.
array = ["Tree", "House"]
house = array.select { |item| item.length > 4}
Fabian Pijpers
Courses Plus Student 41,372 PointsThank you for giving me this detailed help on where to start looking at the problem of the challenge.
datavxn
16,180 Pointsdatavxn
16,180 PointsThe challenge asks to create a new array named house, pulling in any "item" from the array variables above, whose length is greater than four characters, therefore you must check the length (.length) of all items in the array (iterate), by checking the argument in the block, so "item". Your code is almost there and should look like this:
array = ["Tree", "House"] house = array.select { |item| item.length > 4}
Informationally, you don't need "char" before .length, and using == is asking it to check length equal to 4.
Hope this helps!