Navbar with sidebar

can anyone explain this javascript code to me, please?
I am trying to duplicate this effect. like on these pages here

I am trying to show the content of my selection on a navbar shown in the sidebar. like this: C++ Programming Language - GeeksforGeeks

I am afraid there is no easy way to achieve that withoiut having some knowledge with HTML, CSS, JS. If you give us a bit of a background on your personal skills, maybe you would get some directions on where you can start

Thank your for your reply!
I have a decent knowledge of HTML and CSS. however, on JavaScript is limited on implementation.

Is there anyone else who would like to share his or her experience?