Create a button and include Javascript

I’ve got the following script from W3school. I would like to implement this as a button on my startpage, but I have no idea where to start?

How can I include this, so I could create a toggle for fullscreen / exit fullscreen? Anybody any idea?

edit: how do I show code?

Link is here:
https://www.w3schools.com/howto/howto_js_fullscreen.asp