Is it possible to use a global window function withing wiki pages js script macro?

Without having to deep dive into java, I am trying to use a javascript function within my wiki pages.
Script is here

I’ve read through the script macro page and saw that i can use and return javascript code.

So what i did was in Administer Wiki > Look & Feel > Presentation, i added the following line at the end of HTTP Meta Info
<script src="https://example.com/xwiki/date.js"></script>

In my sandbox, i added the following to my wiki page

{{script language="javascript"}}
window.wb.getDateForWeekDayInWeek(1,0)
{{/script}}

This leaves the following error message:

Failed to execute the [script] macro. Cause: [ReferenceError: "window" is not defined]. Click on this message for details.

Same error if i remove the window.wb. portion.

{{script language="javascript"}}
getDateForWeekDayInWeek(1,0)
{{/script}}

I am using the 14.7 postgres-tomcat image in docker.

@multinerd it is very simple to write JS code in XWiki. You can look at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/SkinExtensionsTutorial/ to see how to properly do it.