Birthe Vandermeeren17,139 Points
My solution to Guil's challenge of hiding the non-working buttons
I've created a function hideNonWorkingButtons that first loops through all buttons in the list to set their visibility to "visible".
Then, it sets the visibility of the up button of the first item in the list and the visibility of the down button of the last item in the list to "hidden".
I'm calling this function after all the buttons are created so the right buttons are hidden on the start screen. Then I'm calling it again at the end of the listUl.addEventListener, so it hides the correct buttons when one of the up, down, or remove buttons are clicked. And again at the end of the addItemButton.addEventListener, so it hides the correct buttons when an item is added to the list.
Hope this makes sense. If you have any questions, I'd be happy to clarify.
Here's my the link to my workspace: workspace with function to hide the non-working buttons