How was this Javascript created? Are you importing it from another file or is it inline? Make sure the import happens before the calculation if it is imported.
Unfortunately, since this code doesn't seem to be generated by any WebAssist products, it is not supported by us, but there may be users on the forum that can help you on this issue.