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

JavaScript JavaScript and the DOM (Retiring) Traversing the DOM Getting the First and Last Child

Solution to challenge... please critique!

I finally did it, and it took many hours. Please let me know how it is. Somehow I have this nagging feeling I did it the hard way.

https://w.trhou.se/15vhwyjtnm

Thank you!

1 Answer

Hi, Jesse Vorvick!

Somehow I have this nagging feeling I did it the hard way.

I often have that same feeling. :)

If I understand the objective of this code challenge correctly, you want to not show the ‘up’ or ‘down’ buttons when they are not needed.

Your solution works fine to accomplish that.

Another approach would be to control the visibility of the buttons through CSS. You could use selectors to identify whether a list item was at the top or the bottom of the list. And then control the visibility of the unneeded button that is inside that list item.

A couple of ways to control whether something shows: “display: none” would hide an element and also remove it from the page flow. “visibility:hidden” would hide an element while still filling its place on the page (keeping alignment etc. the same).