There's a button to toggle whether these lines are shown or hidden. Implementing this button's behavior using JavaScript seems perfectly reasonable to me.
I appreciate this. There are too many times that example code omits things and as someone new you get confused as to what the boiler plate is you should use.
Yes, you want to be able to show people that it needs additional context to work, and what that context is.