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 trialJoshua Paulson
37,085 PointsWow this is a struggle, feeling like I'm very close but no cigar. Please help
What's wrong with my code, not sure what's wrong with this picture. Thought I was on point can someone please elaborate where I went wrong?
def find_index(name)
index = 0
found = false
todo_items.each do |todo_item|
if todo_item.name == name
found = true
break;
end
index += 1
end
if found
return index
else
return nil
end
end
1 Answer
Allison Hanna
36,222 PointsIt looks like you have an extra end statement in there. This should work:
''' def find_index(name) index = 0 found = false
todo_items.each do |todo_item|
if todo_item.name == name
found = true
break;
end
index += 1
end
if found
return index
else
return nil
end
end '''
Allison Hanna
36,222 PointsAllison Hanna
36,222 PointsAh, sorry the formatting messed up.
Joshua Paulson
37,085 PointsJoshua Paulson
37,085 PointsThank you much. I really appreciate that you explained rather than just posted the code. Excellent work!