Default export is not a function

What I’m trying to do

I am using Templater to populate a template file for meeting notes with some basic data (filename, topic, date, etc.) — I also want to use part of the filename (to be exact, the last word) for a frontend element called title.
The template looks somewhat like this:

<%*
let var_customer = await tp.system.prompt("Customer Name")
-%>

---
title: <% tp.user.getlastword(file.name) %>
date: <% tp.file.creation_date("YY-MM-DD") %>
tags: mtg_minutes

---

customer: <% var_customer %>

topic: <% tp.file.cursor() %>

As you can see, I have defined a JS function for the title based on the function getLastWord. That JS function is looking as follows:

function getLastWord(str) { 
// Split the string into an array of words 
	const words = str.split(' '); 
// Return the last word in the array 
	return words.pop(); 
    
}
module.exports = getLastWord();

However, when I am trying to use the template, I continuously get the error message “Default export is not a function”.

Things I have tried

I try to simply export the function via export = getLastWord(); - that does not work as well.

I am not quite sure what I am missing here - any help is highly appreciated :wink:

Thanks a lot!