Anyone who has left the low code area has probably used VS Code in recent times to format JavaScript.
As soon as you are using variables you will have noticed that the code formatting destroyed the variable definition.
This is how it looked before when the code was copied back to designer studio.
The easiest way to fix this, is a custom key binding so that you can execute a search & replace action with fixed patterns. All you need to do afterwards is to execute three actions:
You can find more details here.