One of the things I find myself double-checking syntax on is how to pass a variable value from one language to the other. Because they are 2 completely different languages, they need us to help move data between them.
The good news is that SSJS can push the data back and forth, so we just need to learn the SSJS functions Variable.GetValue() and Variable.SetValue().
GetValue is used when you have an AMPScript variable you want to pass into your SSJS.
To work, you need to set a value on an AMPscript variable before you open your script tags.
Set Value is used when you have a SSJS variable you want to pass into AMPscript.
This allows you to set an AMPscript variable from within your SSJS script. It will work with both a set value or a variable’s value.