Run jsobject in text field

Hi i have this script js
export default {
myVar1: [],
myVar2: {},
next_service: () => {
if(!last_service.formattedDate) {return ''}
var dt = new Date(last_service.formattedDate)
dt.setMonth( dt.getMonth() + interval.text );
return dt
}
}

i just added that to my script section but its giving me error attached image the idea is to change a field (next_service) depending on two other fields (last_service and interval)

Hello! I think export default might not work as expected here. Are you able to have the same functionality without the export default?

It doesn't work

How exactly would you like to use this JS? Are you ideally running it whenever last_service and interval change?